An example of the code for our simulation clock

    #if an isotope changes, don't forget to check the rest in the ENVIRONMENT
    #true until there are only stable isotopes
    #decays are used to determine if there are elements in the ENVIRONMENT that
    #may decay at that granular time
 
    while True:
        while smt.d < 365 and smt.decay_d:
           
            #leap years
            if not (smt.y % 4 == 0):
                smt.d += 1

            while smt.h < 24 and smt.decay_h:
                if not smt.decay_m:
                    check_environment(smt.h)
                while smt.m < 60 and smt.decay_m:
                    if not smt.decay_m:
                        check_environment(smt.m)
                    while smt.s < 60 and smt.decay_s:          
                        if not smt.decay_ms:
                            check_environment(smt.s)
                        while smt.ms < 100 and smt.decay_ms:
                            check_environment(smt.ms):                              
                            if smt.ms % 20 == 0:                              
                                print (smt.y,':',smt.d,':',smt.h,
                                       ':',smt.m,':',smt.s,':',smt.ms)
                            smt.ms = smt.ms + 10
                        smt.s = smt.s + 10
                        smt.ms = 0
                    smt.m = smt.m + 10
                    smt.s = 0
                smt.h = smt.h + 1  
                smt.m = 0
            smt.d = smt.d + 1
            smt.h = 0                
        smt.y = smt.y + 1
        smt.d = 0
        #set to terminate at 10 years, for validation
        if smt.y == 10:
            print ('done')
            break

Some Personal Adventures in Python: Writing to .csv

Although I am aware that Python has modules for graphing and working tests on data, I am not familiar with those modules (matplotlib, numpy, scipy), and am intent on pursuing the use of Python script that outputs to a .csv file that I can then read from MS Excel, and work more comfortably with the tools there.

Here's a solution that I have chosen:

1. You have to use "import csv", which shouldn't be an issue since it comes packaged in the standard library.

2. Read http://docs.python.org/3/library/csv.html and maybe
http://yuji.wordpress.com/2008/05/14/python-basics-of-python-dictionary-and-looping-through-them/ and 
http://www.python.org/dev/peps/pep-0305/

If that still doesn't provide enough information, there is this, which talks about how to write dictionaries to .csv format:
http://stackoverflow.com/search?q=python+dictwriter

3. Now, feeling solid with the information, I decide not to write dictionaries at all, but go a slightly different route. For me, for printing out a series of states, labeled with the elements, and that can hold a quantity seems much more a list application; rather, best is a 3 dimensional array that has Array1: Elements that exist at Array2: State at Array3 quantity, which, graphed, would give a nice representation of the data.

That, though, goes beyond what I'm trying to accomplish at the moment.

So, what I have to start with is a Dictionary, which, if you don't know Python, are un-ordered name-value pairs; rather { 'key' : 'value', 'key2' : 'value2', ... : ... , 'keyn' : 'value' }. In the simulation script, the keys are the name of elements.

To print out a row of names, followed by a row of their values, I came up with the following:

Now, this only accounts for a single state, but for what I'm doing, that's okay. If I want to create a 2D array, where states are represented on the y-axis, I would refactor like so:


Once this is ran, I just open the results.csv in MS Excel and can continue to work with the data there.