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

No comments:

Post a Comment