def __init__(self, master, system, reaction, editflag):
        """Constructor method.  Makes the GUI using the list of "Layer" objects
        "layers." """

        # Read the Tkinter information
        self.master = master
        self.fonttype = system.fonttype
        self.formulatype = system.formulatype
        self.version = system.version
        self.superfont = get_superfont(self.fonttype)
        self.subfont = get_superfont(self.formulatype)
        self.tframe = Frame(master.tframe)
        self.frame = Frame(master.frame)
        self.bframe = Frame(master.bframe)
        self.bgcolor = self.frame.cget('bg')
        self.top = None

        self.system = system

        # Read the system information
        self.chemicals = system.chemicals
        self.reaction = reaction
        self.editflag = editflag

        # Define the reaction chemical information
        self.chemical_list = [chemical.name for chemical in self.chemicals]
        self.formula_list = [chemical.formula for chemical in self.chemicals]
        self.MW_list = [chemical.MW for chemical in self.chemicals]

        self.models = ['Fundamental', 'User-defined']

        self.name = StringVar(value='Reaction ' + str(reaction.number))
        self.model = StringVar(value=self.models[0])
        self.reactants = []
        self.products = []

        #self.stoichcoef = reaction.stoichcoef
        if editflag == 1:

            self.name = StringVar(value=reaction.name)
            self.model = StringVar(value=reaction.model)
            self.reactants = [
                reactant.copy() for reactant in reaction.reactants
            ]
            self.products = [product.copy() for product in reaction.products]

            for reactant in self.reactants:
                reactant.coef = DoubleVar(value=reactant.coef)
                reactant.index = DoubleVar(value=reactant.index)
                reactant.name = StringVar(value=reactant.name)
                reactant.formula = StringVar(value=reactant.formula)
                reactant.MW = DoubleVar(value=reactant.MW)

            for product in self.products:
                product.coef = DoubleVar(value=product.coef)
                product.name = StringVar(value=product.name)
                product.formula = StringVar(value=product.formula)
                product.MW = DoubleVar(value=product.MW)

        self.cancelflag = 0
    def __init__(self, master, system, editflag = None):
        """Constructor method. Used to defines the layers."""
        
        self.fonttype     = system.fonttype
        self.version      = system.version
        self.master       = master
        self.frame        = Frame(master.frame)
        self.tframe       = Frame(master.tframe)
        self.bframe       = Frame(master.bframe)
        self.superfont    = get_superfont(self.fonttype)
        self.top          = None

        self.system       = system
        self.lengthunit   = system.lengthunit

        if system.layers is None:
            self.layers  = []
            self.nlayers = 0
        else:
            self.layers  = system.layers
            self.nlayers = system.nlayers

        self.editflag = editflag

        print(editflag)
        if editflag == 1:
            self.num_record         = [j for j in range(self.nlayers)]
    def __init__(self, master, system, solid):
        """Constructor method.  Defines the parameters to be obtained in this
        window."""

        self.master = master
        self.fonttype = system.fonttype
        self.version = system.version
        self.superfont = get_superfont(self.fonttype)  #superscript font
        self.tframe = Frame(master.tframe)
        self.frame = Frame(master.frame)
        self.bframe = Frame(master.bframe)
        self.top = None  #flag for existence of toplevel#

        self.name = StringVar(value=solid.name)  #stores the chemical name
        self.e = DoubleVar(value=solid.e)  #stores the porosity
        self.rho = DoubleVar(value=solid.rho)  #stores the bulk density
        self.foc = DoubleVar(
            value=solid.foc)  #stores the organic carbon fraction
        self.tort = StringVar(
            value=solid.tort)  #stores the default tortuosity correction
        self.sorp = StringVar(
            value=solid.sorp)  #stores the default sorption correction
        self.Ref = StringVar(
            value=solid.Ref)  #stores the default sorption correction

        self.cancelflag = 0
Beispiel #4
0
    def __init__(self, master, system, database):
        """The constructor method."""

        self.system = system
        self.version = system.version
        self.fonttype = system.fonttype
        self.sfont = get_superfont(self.fonttype)
        self.master = master
        self.tframe = Frame(master.tframe)
        self.frame = Frame(master.frame)
        self.bframe = Frame(master.bframe)
        self.top = None

        self.database = database  #the database of values

        self.exitflag = 0
        self.names = []  #a list of the chemical names

        solids_list = self.database.keys()
        solids_list.sort()

        self.solids_list = solids_list

        self.solids = []
        for solidname in solids_list:
            self.solids.append(Solid(solids_list.index(solidname)))
            self.solids[-1].read_database(self.database[solidname])
Beispiel #5
0
    def __init__(self, master, system, chemical):
        """Constructor method. Defines the parameters to be obtained in this window."""

        self.master = master
        self.fonttype = system.fonttype
        self.version = system.version
        self.superfont = get_superfont(self.fonttype)  #superscript font
        self.frame = Frame(master.frame)
        self.tframe = Frame(master.tframe)
        self.bframe = Frame(master.bframe)
        self.top = None  #flag for existence of toplevel#

        self.soluableflag = chemical.soluable
        self.name = StringVar(value=chemical.name)
        self.MW = DoubleVar(value=chemical.MW)
        self.formula = StringVar(value=chemical.formula)
        self.temp = DoubleVar(value=chemical.temp)
        self.Dw = DoubleVar(value=chemical.Dw)
        self.Koc = DoubleVar(value=chemical.Koc)
        self.Kdoc = DoubleVar(value=chemical.Kdoc)
        self.Ref = StringVar(value=chemical.Ref)
        self.Kf = DoubleVar(value=chemical.Kf)
        self.N = DoubleVar(value=chemical.N)

        self.chemical = chemical

        self.cancelflag = 0
Beispiel #6
0
    def __init__(self, master, version, fonttype, timeunit, lengthunit,
                 chemicals, taucoefs, BCs):
        """Constructor method."""

        self.master = master
        self.version = version
        self.fonttype = fonttype
        self.tframe = Frame(master.tframe)
        self.frame = Frame(master.frame)
        self.bframe = Frame(master.bframe)
        self.superfont = get_superfont(self.fonttype)

        self.Decays = ['None', 'First order']
        self.Evaps = ['None', 'First order']
        self.top = None

        self.cancelflag = 0

        self.timeunit = timeunit
        self.lengthunit = lengthunit

        self.Q = DoubleVar(value=taucoefs['Q'])
        self.V = DoubleVar(value=taucoefs['V'])
        self.h = DoubleVar(value=taucoefs['h'])
        self.Qevap = DoubleVar(value=taucoefs['Qevap'])
        self.doc = DoubleVar(value=taucoefs['DOC'])
        self.Decay = StringVar(value=taucoefs['Decay'])
        self.Evap = StringVar(value=taucoefs['Evap'])

        self.chemicals = chemicals
        self.kdecays = []
        self.kevaps = []
        for chemical in self.chemicals:
            self.kdecays.append(BCs[chemical.name].kdecay)
            self.kevaps.append(BCs[chemical.name].kevap)
Beispiel #7
0
    def __init__(self, master, version, fonttype, bltype, blcoefs):
        """Constructor method."""

        self.version = version
        self.fonttype = fonttype
        self.tframe = Frame(master.tframe)
        self.frame = Frame(master.frame)
        self.bframe = Frame(master.bframe)
        self.superfont = get_superfont(self.fonttype)

        self.bltypes = ['River', 'Lake']
        self.bltype = StringVar(value=bltype)
        self.top = None

        self.cancelflag = 0

        #Parameters for Mass transfer coefficient in river
        self.vx = DoubleVar(value=blcoefs['vx'])
        self.n = DoubleVar(value=blcoefs['n'])
        self.hriver = DoubleVar(value=blcoefs['hriver'])
        self.rh = DoubleVar(value=blcoefs['rh'])
        self.nu = DoubleVar(value=blcoefs['nu'])

        #Parameters for Mass transfer coefficient in lake
        self.rhoair = DoubleVar(value=blcoefs['rhoair'])
        self.rhowater = DoubleVar(value=blcoefs['rhowater'])
        self.vwind = DoubleVar(value=blcoefs['vwind'])
        self.hlake = DoubleVar(value=blcoefs['hlake'])
        self.llake = DoubleVar(value=blcoefs['llake'])
    def __init__(self, master, system, database_imported):
        """The constructor method."""

        self.version = system.version
        self.fonttype = system.fonttype
        self.sfont = get_superfont(self.fonttype)
        self.master = master
        self.tframe = Frame(master.tframe)
        self.frame = Frame(master.frame)
        self.bframe = Frame(master.bframe)
        self.tkfont = tkFont.Font(font=system.fonttype)

        solids_list = database_imported.keys()
        solids_list.sort()

        self.solids_list = solids_list

        self.name_width = 10

        for chemical_name in self.solids_list:
            if (self.tkfont.measure(chemical_name) + 10) > self.name_width:
                self.name_width = self.tkfont.measure(chemical_name) + 10

        if self.name_width < 150: self.name_width = 150

        self.solids = []
        for solidname in self.solids_list:
            self.solids.append(Solid(solids_list.index(solidname)))
            self.solids[-1].read_database(database_imported[solidname])

        self.sname = StringVar(self.frame, value='')

        self.cancelflag = 0
    def __init__(self, master, system):
        """Constructor method.  Defines the parameters to be obtained in this window."""

        self.master = master
        self.fonttype = system.fonttype
        self.version = system.version
        self.superfont = get_superfont(self.fonttype)  #superscript font
        self.tframe = Frame(master.tframe)
        self.frame = Frame(master.frame)
        self.bframe = Frame(master.bframe)
        self.top = None  #flag for existence of toplevel#

        self.lengthunits = [u'\u03BCm', 'cm', 'm']
        self.concunits = [
            u'\u03BCg/L', 'mg/L', 'g/L', u'\u03BCmol/L', 'mmol/L', 'mol/L'
        ]
        self.timeunits = ['s', 'min', 'hr', 'day', 'yr']
        self.diffunits = [u'cm\u00B2/s', u'cm\u00B2/yr']

        self.lengthunit = StringVar(value=self.lengthunits[1])
        self.concunit = StringVar(value=self.concunits[0])
        self.timeunit = StringVar(value=self.timeunits[4])
        self.diffunit = StringVar(value=self.diffunits[0])

        self.system = system
    def __init__(self, master, system):
        """Constructor method. Used to defines the layers."""

        self.fonttype = system.fonttype
        self.version = system.version
        self.master = master
        self.frame = Frame(master.frame)
        self.tframe = Frame(master.tframe)
        self.bframe = Frame(master.bframe)
        self.sfont = get_superfont(self.fonttype)
        self.top = None

        self.system = system
        self.chemicals = system.chemicals
        self.matrices = system.matrices
        self.timeunit = system.timeunit
        self.concunit = system.concunit

        self.defaults = 0
        if master.master is None: self.defaults = 1

        self.components = system.components
        self.component_list = system.component_list

        if system.sorptions is None:
            self.sorptions = {}
            for component in self.components:
                self.sorptions[component.name] = {}
                for chemical in self.chemicals:
                    self.sorptions[component.name][chemical.name] = Sorption(
                        component, chemical, unit=system.concunit)
        else:
            self.sorptions = system.sorptions
    def __init__(self, master, system):
        """Constructor method.  Defines the parameters to be obtained in this
        window."""

        self.master = master
        self.system = system
        self.fonttype = system.fonttype
        self.version = system.version
        self.superfont = get_superfont(self.fonttype)  #superscript font
        self.tframe = Frame(master.tframe)
        self.frame = Frame(master.frame)
        self.bframe = Frame(master.bframe)

        self.advs = ['None', 'Steady flow', 'Period oscillation']
        self.bios = ['None', 'Uniform', 'Depth-dependent']
        self.cons = ['None', 'Consolidation']

        self.adv = StringVar(value=self.advs[0])  #tidal flag
        self.bio = StringVar(value=self.bios[0])  #bioturbation flag
        self.con = StringVar(value=self.cons[0])  #consolidation flag

        self.hbio = DoubleVar(value=10.)  #bioturbation depth
        self.sigma = DoubleVar(value=10.)  #bioturbation depth
        self.Dbiop = DoubleVar(value=1.)  #particle bioturbation coeff
        self.Dbiopw = DoubleVar(value=100.)  #pore water bioturbation coeff
        self.Vdar = DoubleVar(value=0.)  #Darcy velocity
        self.Vtidal = DoubleVar(value=0.)  #Tidal velocity
        self.ptidal = DoubleVar(value=0.0014)  #Tidal frequency
        self.hcon = DoubleVar(value=0)  #total consolidation
        self.t90 = DoubleVar(value=1.)  #time to 90% consolidation
        self.top = None  #flag for existence of toplevel

        if system.layers[0].number == 0: self.toplayer_h = system.layers[1].h
        else: self.toplayer_h = system.layers[0].h

        self.lengthunit = system.lengthunit
        self.timeunit = system.timeunit
        self.diffunit = system.diffunit
        self.diffunits = system.diffunits

        try:
            self.adv.set(system.adv)
            self.bio.set(system.bio)
            self.con.set(system.con)
            self.Vdar.set(system.Vdar)

            self.hbio.set(system.hbio)
            self.sigma.set(system.sigma)
            self.Dbiop.set(system.Dbiop)
            self.Dbiopw.set(system.Dbiopw)

            self.Vtidal.set(system.Vtidal)
            self.ptidal.set(system.ptidal)

            self.hcon.set(system.hcon)
            self.t90.set(system.t90)
        except:
            pass
Beispiel #12
0
    def __init__(self, master, system, layer, layers, editflag):
        """Constructor method.  Defines the parameters to be obtained in this
        window."""

        self.master = master
        self.fonttype = system.fonttype
        self.version = system.version
        self.superfont = get_superfont(self.fonttype)  #superscript font
        self.tframe = Frame(master.tframe)
        self.frame = Frame(master.frame)
        self.bframe = Frame(master.bframe)
        self.top = None  #flag for existence of toplevel#

        self.system = system
        self.lengthunit = system.lengthunit

        self.layer = layer
        self.layers = layers
        self.types = []
        self.tort_types = []

        self.torts = layer.torts
        self.h = DoubleVar(value=10.0)
        self.alpha = DoubleVar(value=1.0)
        self.doc = DoubleVar(value=0.0)

        for matrix in system.matrices:
            self.types.append(matrix.name)
            self.tort_types.append(matrix.components[0].tort)

        self.type = StringVar(value=self.types[0])
        self.tort = StringVar(value=self.tort_types[0])

        self.editflag = editflag
        self.cancelflag = 0

        if self.editflag == 1:
            self.type.set(layer.type)
            self.tort.set(layer.tort)
            self.h.set(layer.h)
            self.alpha.set(layer.alpha)
            self.doc.set(layer.doc)

        self.names = []
        if len(layers) == 0:
            self.names.append('Deposition')
            self.names.append('Layer 1')
        else:
            for layer in self.layers:
                self.names.append(layer.name)
            self.names.append('Layer ' + str(layers[-1].number + 1))
            if self.names[0] == 'Deposition': self.names.remove(self.names[0])
            else: self.names.insert(0, 'Deposition')

        if self.editflag == 0: self.name = StringVar(value=self.names[-1])
        else: self.name = StringVar(value=self.layer.name)
    def __init__(self, master, system):
        """Constructor method. Used to defines the layers."""
        
        self.master         = master
        self.system         = system
        self.version        = system.version
        self.fonttype       = system.fonttype
        self.formulatype    = system.formulatype
        self.superfont      = get_superfont(self.fonttype)
        self.subfont        = get_superfont(self.formulatype)
        self.tframe         = Frame(master.tframe)
        self.frame          = Frame(master.frame)
        self.bframe         = Frame(master.bframe)
        self.bgcolor        = self.frame.cget('bg')
        self.top            = None

        self.chemicals      = system.chemicals
        
        if master.master is None: self.defaults = 1

        if system.reactions is None: self.reactions      = []
        else:                        self.reactions      = system.reactions
Beispiel #14
0
    def __init__(self, master, system, database):
        """The constructor method."""

        self.version = system.version
        self.fonttype = system.fonttype
        self.sfont = get_superfont(self.fonttype)
        self.master = master
        self.frame = Frame(master.frame)
        self.tframe = Frame(master.tframe)
        self.bframe = Frame(master.bframe)
        self.tkfont = tkFont.Font(font=system.fonttype)

        self.chemicals_list = database.keys()
        self.chemicals_list.sort()

        self.name = StringVar()
        self.formula = StringVar()
        self.MW = DoubleVar()
        self.temp = DoubleVar(value=0)
        self.Dw = DoubleVar(value=0)
        self.Ref = StringVar(value=0)
        self.Koc = DoubleVar(value=0)
        self.Kdoc = DoubleVar(value=0)
        self.Kf = DoubleVar(value=0)
        self.N = DoubleVar(value=0)

        self.importedchemicals = {}
        for name in self.chemicals_list:
            self.importedchemicals[name] = ChemicalData(name)
            self.importedchemicals[name].read_database(database[name])

        self.name_width = 10
        self.ref_width = 10

        for chemical_name in self.chemicals_list:
            if (self.tkfont.measure(chemical_name) + 10) > self.name_width:
                self.name_width = self.tkfont.measure(chemical_name) + 10
            for temp in self.importedchemicals[chemical_name].temps:
                if (self.tkfont.measure(
                        self.importedchemicals[chemical_name].Ref[temp]) +
                        10) > self.name_width:
                    self.name_width = self.tkfont.measure(
                        self.importedchemicals[chemical_name].Ref[temp]) + 10

        if self.name_width < 150: self.name_width = 150
        if self.ref_width < 150: self.ref_width = 150

        self.cancelflag = 0

        self.sname = StringVar(self.frame, value='')
Beispiel #15
0
    def __init__(self, master, system, matrix, matrices, materials, editflag,
                 newflag):
        """Constructor method.  Defines the parameters to be obtained in this
        window."""

        self.master = master
        self.fonttype = system.fonttype
        self.version = system.version
        self.superfont = get_superfont(self.fonttype)  #superscript font
        self.tframe = Frame(master.tframe)
        self.frame = Frame(master.frame)
        self.bframe = Frame(master.bframe)
        self.top = None  #flag for existence of toplevel#

        self.matrix = matrix
        self.matrices = matrices
        self.materials = materials

        self.matrices_list = self.materials.keys()
        self.matrices_list.sort()
        for matrix in (self.matrices):
            if matrix.number <> self.matrix.number and len(
                    matrix.components) == 1 and self.matrices_list.count(
                        matrix.name) > 0:
                self.matrices_list.remove(matrix.name)

        self.model = StringVar(
            value='Linear')  #Define the imaginary model for the components

        self.name = StringVar(value=self.matrices_list[0])  #matrix name
        self.e = DoubleVar(value=0.5)  #stores the porosity
        self.rho = DoubleVar(value=1.0)  #stores the bulk density
        self.foc = DoubleVar(value=0.01)  #stores the organic carbon fraction

        self.editflag = editflag
        self.newflag = newflag
        self.cancelflag = 0

        if editflag == 0:
            self.components = [MatrixComponent(1)]  #Define components

        if editflag == 1:  #Detemine whether the chemical is added or edited

            self.components = self.matrix.components
            self.name.set(self.matrix.name)
            self.model.set(self.matrix.model)
            self.e.set(self.matrix.e)
            self.rho.set(self.matrix.rho)
            self.foc.set(self.matrix.foc)
    def __init__(self, master, system, reactants):
        """Constructor method.  Makes the GUI using the list of "Layer" objects
        "layers." """

        self.master = master
        self.fonttype = system.fonttype
        self.version = system.version
        self.superfont = get_superfont(self.fonttype)
        self.tframe = Frame(master.tframe)
        self.frame = Frame(master.frame)
        self.bframe = Frame(master.bframe)
        self.bgcolor = self.frame.cget('bg')
        self.top = None

        self.reactants = reactants
    def __init__(self, master, system, solid, solid_database, editflag):
        """Constructor method.  Defines the parameters to be obtained in this
        window."""

        self.master = master
        self.fonttype = system.fonttype
        self.version = system.version
        self.superfont = get_superfont(self.fonttype)  #superscript font
        self.tframe = Frame(master.tframe)
        self.frame = Frame(master.frame)
        self.bframe = Frame(master.bframe)
        self.top = None  #flag for existence of toplevel#

        self.solid = solid
        self.solid_database = solid_database

        self.torts = ['Millington & Quirk', 'Boudreau', 'None']
        self.sorps = [
            'Linear--Kd specified', 'Linear--Kocfoc', 'Freundlich', 'Langmuir'
        ]

        self.name = StringVar(
            value='Solid ' +
            str(solid_database[-1].number))  #stores the chemical name
        self.e = DoubleVar(value=0.5)  #stores the porosity
        self.rho = DoubleVar(value=1.0)  #stores the bulk density
        self.foc = DoubleVar(value=0.01)  #stores the organic carbon fraction
        self.tort = StringVar(
            value=self.torts[0])  #stores the default tortuosity correction
        self.sorp = StringVar(
            value=self.sorps[0])  #stores the default sorption correction
        self.Ref = StringVar(value='')  #stores the density

        self.editflag = editflag
        self.cancelflag = 0

        if editflag == 1:  #Detemine whether the chemical is added or edited

            self.name.set(solid.name)
            self.e.set(solid.e)
            self.rho.set(solid.rho)
            self.foc.set(solid.foc)
            self.tort.set(solid.tort)
            self.sorp.set(solid.sorp)
            self.Ref.set(solid.Ref)
Beispiel #18
0
    def __init__(self, master, system, matrix, matrices, materials, editflag):
        """Constructor method.  Defines the parameters to be obtained in this
        window."""

        self.master = master
        self.fonttype = system.fonttype
        self.version = system.version
        self.superfont = get_superfont(self.fonttype)  #superscript font
        self.tframe = Frame(master.tframe)
        self.frame = Frame(master.frame)
        self.bframe = Frame(master.bframe)
        self.top = None  #flag for existence of toplevel#

        self.matrix = matrix
        self.matrices = matrices
        self.materials = materials

        self.mixing_models = ['Linear', 'None']

        self.name = StringVar(value='Mixture')  #matrix name
        self.model = StringVar(value=self.mixing_models[0])  #model name
        self.e = DoubleVar()  #stores the porosity
        self.rho = DoubleVar()  #stores the bulk density
        self.foc = DoubleVar()  #stores the organic carbon fraction

        self.components = []  #components

        self.editflag = editflag
        self.cancelflag = 0

        if editflag == 1:  #Detemine whether the chemical is added or edited

            for component in self.matrix.components:
                self.components.append(component.copy())
                self.components[-1].name = StringVar(
                    value=self.components[-1].name)
                self.components[-1].mfraction = DoubleVar(
                    value=self.components[-1].mfraction)

            self.name.set(self.matrix.name)
            self.model.set(self.matrix.model)
            self.e.set(self.matrix.e)
            self.rho.set(self.matrix.rho)
            self.foc.set(self.matrix.foc)
Beispiel #19
0
    def __init__(self, master, version, fonttype, timeunit, chemicals,
                 kdecays):
        """Constructor method."""

        self.version = version
        self.fonttype = fonttype
        self.tframe = Frame(master.tframe)
        self.frame = Frame(master.frame)
        self.bframe = Frame(master.bframe)
        self.superfont = get_superfont(self.fonttype)

        self.cancelflag = 0

        self.timeunit = timeunit
        self.chemicals = chemicals

        self.kdecays = []
        for n in range(len(self.chemicals)):
            self.kdecays.append(DoubleVar(value=kdecays[n]))
    def __init__(self, master, system, sorption):
        
        """Constructor method.  Defines the parameters to be obtained in this
        window."""
        
        self.master     = master
        self.fonttype   = system.fonttype
        self.version    = system.version
        self.sfont      = get_superfont(self.fonttype)  #superscript font
        self.frame      = Frame(master.frame)
        self.tframe     = Frame(master.tframe)
        self.bframe     = Frame(master.bframe)
        self.top        = None                   #flag for existence of toplevel#

        self.system     = system

        self.isotherms      = ['Linear--Kd specified', 'Linear--Kocfoc', 'Freundlich', 'Langmuir']
        self.kinetics       = ['Equilibrium', 'Transient']

        self.sorption   = sorption
            
        self.isotherm   = StringVar(value = sorption.isotherm)
        self.kinetic    = StringVar(value = sorption.kinetic)
        self.K          = DoubleVar(value = sorption.K)
        self.Koc        = DoubleVar(value = sorption.Koc)
        self.Kf         = DoubleVar(value = sorption.Kf)
        self.N          = DoubleVar(value = sorption.N)
        self.qmax       = DoubleVar(value = sorption.qmax)
        self.b          = DoubleVar(value = sorption.b)
        self.ksorp      = DoubleVar(value = sorption.ksorp)

        self.cinit      = sorption.cinit
        self.qinit      = sorption.qinit
        self.thalf      = sorption.thalf

        self.concunit   = system.concunit
        self.timeunit   = system.timeunit

        self.tkfont      = tkFont.Font(font = self.fonttype)

        self.cancelflag = 0
Beispiel #21
0
    def __init__(self, master, system, layer):
        """Constructor method.  Defines the parameters to be obtained in this
        window."""

        self.master = master
        self.fonttype = system.fonttype
        self.version = system.version
        self.superfont = get_superfont(self.fonttype)  #superscript font
        self.tframe = Frame(master.tframe)
        self.frame = Frame(master.frame)
        self.bframe = Frame(master.bframe)
        self.top = None  #flag for existence of toplevel#

        self.type = layer.type
        self.tort = layer.tort
        self.h = layer.h
        self.alpha = layer.alpha
        self.doc = layer.doc

        self.layer = layer
        self.cancelflag = 0
    def __init__(self, master, system, isotherm, coef):
        """Constructor method.  Makes the GUI using the list of "Layer" objects
        "layers." """

        self.master     = master
        self.fonttype   = system.fonttype
        self.version    = system.version
        self.superfont  = get_superfont(self.fonttype)
        self.tframe     = Frame(master.tframe)
        self.frame      = Frame(master.frame)
        self.bframe     = Frame(master.bframe)
        self.bgcolor    = self.frame.cget('bg')
        self.top        = None

        self.concunit   = system.concunit
        self.timeunit   = system.timeunit

        self.cinit      = DoubleVar(value = coef[0])
        self.qinit      = DoubleVar(value = coef[1])
        self.thalf      = DoubleVar(value = coef[2])
        self.ksorp      = DoubleVar(value = coef[3])

        self.coef       = coef

        self.isotherms      = ['Linear--Kd specified', 'Linear--Kocfoc', 'Freundlich', 'Langmuir']
        self.isotherm       = isotherm

        if self.isotherm == self.isotherms[0]:
            self.Kd = coef[4]
        if self.isotherm == self.isotherms[1]:
            self.Kd = 10 ** coef[4]*coef[5]
        if self.isotherm == self.isotherms[2]:
            self.Kf = coef[4]
            self.N  = coef[5]
        if self.isotherm == self.isotherms[3]:
            self.qmax = coef[4]
            self.b    = coef[5]

        self.epsilon = coef[6]
        self.rho     = coef[7]
Beispiel #23
0
    def __init__(self, master, system):
        """Constructor method.  Makes the GUI using the list of "Layer" objects
        "layers." """

        self.master = master
        self.version = system.version
        self.fonttype = system.fonttype
        self.superfont = get_superfont(self.fonttype)
        self.tframe = Frame(master.tframe)
        self.frame = Frame(master.frame)
        self.bframe = Frame(master.bframe)
        self.lframe = Frame(master.lframe)

        self.bgcolor = self.frame.cget('bg')
        self.top = None

        self.nchemicals = system.nchemicals
        self.chemicals = system.chemicals
        self.layers = system.layers
        self.matrices = system.matrices
        self.components = system.components
        self.sorptions = system.sorptions

        self.concunit = system.concunit

        self.topline = Label(self.frame, width=10, text='-' * 1000)

        if system.SolidICs == None:
            self.SolidICs = {}
            for layer in system.layers:
                self.SolidICs[layer.name] = {}
                for component in system.matrices[layer.type_index].components:
                    self.SolidICs[layer.name][component.name] = {}
                    for chemical in self.chemicals:
                        self.SolidICs[layer.name][component.name][
                            chemical.name] = SolidIC(layer.name,
                                                     component.name,
                                                     chemical.name)
        else:
            self.SolidICs = system.SolidICs
Beispiel #24
0
    def __init__(self, master, system, materials):

        """Constructor method. Defines the parameters to be obtained in this window."""

        self.master    = master
        self.fonttype  = system.fonttype
        self.version   = system.version
        self.superfont = get_superfont(self.fonttype) #superscript font
        self.tframe    = Frame(master.tframe)
        self.frame     = Frame(master.frame)
        self.bframe    = Frame(master.bframe)
        self.top       = None                   #flag for existence of toplevel#

        self.system    = system
        self.materials = materials

        if system.matrices is None:
            self.matrices  = []
            self.nmatrices = 0
        else:
            self.matrices  = system.matrices
            self.nmatrices = system.nmatrices
Beispiel #25
0
    def __init__(self, master, system, matrix):
        """Constructor method.  Defines the parameters to be obtained in this
        window."""

        self.master = master
        self.fonttype = system.fonttype
        self.version = system.version
        self.superfont = get_superfont(self.fonttype)  #superscript font
        self.tframe = Frame(master.tframe)
        self.frame = Frame(master.frame)
        self.bframe = Frame(master.bframe)
        self.top = None  #flag for existence of toplevel#

        self.matrix = matrix
        self.name = StringVar(value=matrix.name)  #stores the chemical name
        self.model = StringVar(value=matrix.model)  #stores the chemical name
        self.e = DoubleVar(value=matrix.e)  #stores the porosity
        self.rho = DoubleVar(value=matrix.rho)  #stores the bulk density
        self.foc = DoubleVar(
            value=matrix.foc)  #stores the organic carbon fraction

        self.cancelflag = 0
Beispiel #26
0
    def __init__(self, master, system, database):
        """The constructor method."""

        self.version = system.version
        self.fonttype = system.fonttype
        self.sfont = get_superfont(self.fonttype)
        self.master = master
        self.tframe = Frame(master.tframe)
        self.frame = Frame(master.frame)
        self.bframe = Frame(master.bframe)
        self.top = None

        self.system = system
        self.database = database  #the chemical database

        self.chemicals_list = self.database.keys()
        self.chemicals_list.sort()

        self.chemicaldatas = {}

        for name in self.chemicals_list:
            self.chemicaldatas[name] = ChemicalData(name)
            self.chemicaldatas[name].read_database(self.database[name])
    def __init__(self, master, system, database):
        """Constructor method. Defines the parameters to be obtained in this window."""

        self.master = master
        self.fonttype = system.fonttype
        self.version = system.version
        self.superfont = get_superfont(self.fonttype)  #superscript font
        self.tframe = Frame(master.tframe)
        self.frame = Frame(master.frame)
        self.bframe = Frame(master.bframe)
        self.top = None  #flag for existence of toplevel#

        self.system = system
        self.database = database
        self.diffunit = system.diffunit
        self.concunit = system.concunit
        self.concunits = system.concunits

        if system.chemicals is None:
            self.chemicals = []
            self.nchemicals = 0
        else:
            self.chemicals = system.chemicals
            self.nchemicals = system.nchemicals
    def __init__(self, master, system, editflag):
        """Constructor method. Used to defines the layers."""

        self.master = master
        self.version = system.version
        self.fonttype = system.fonttype
        self.formulatype = system.formulatype
        self.superfont = get_superfont(self.fonttype)
        self.subfont = get_superfont(self.formulatype)
        self.tframe = Frame(master.tframe)
        self.frame = Frame(master.frame)
        self.bframe = Frame(master.bframe)
        self.bgcolor = self.frame.cget('bg')
        self.top = None

        self.system = system
        self.concunit = system.concunit
        self.timeunit = system.timeunit

        self.concunits = system.concunits

        # Convert mass concentration units to corresponding molar concentration units
        if self.concunit == system.concunits[0]:
            self.concunit = system.concunits[3]
        if self.concunit == system.concunits[1]:
            self.concunit = system.concunits[4]
        if self.concunit == system.concunits[2]:
            self.concunit = system.concunits[5]

        self.reactions = system.reactions
        self.layers = system.layers
        self.coefficients = system.coefficients

        if system.coefficients == None:
            self.coefficients = {}
            for layer in self.layers:
                layerindex = self.layers.index(layer)
                self.coefficients[layer.name] = {}
                for reaction in self.reactions:
                    self.coefficients[layer.name][reaction.name] = Coefficient(
                        layer, reaction)

        self.name_max = 0
        self.formula_max = 0
        self.rate_max = 0
        self.value_max = 0
        unitindex = 0

        tkfont = tkFont.Font(font=self.formulatype)
        tksubfont = tkFont.Font(font=self.superfont)
        tksuperfont = tkFont.Font(font=self.subfont)

        for reaction in self.reactions:
            if tkfont.measure(reaction.name) > self.name_max:
                self.name_max = tkfont.measure(reaction.name)
            if tkfont.measure(reaction.equation) > self.formula_max:
                self.formula_max = tkfont.measure(reaction.equation)

            rate_len = tkfont.measure(u'r = \u03BB')
            rate_len = rate_len + tksubfont.measure(str(reaction.number) + ',')
            rate_len = rate_len + tksubfont.measure(str(10))
            for reactant in reaction.reactants:
                if reactant.index <> 0:
                    rate_len = rate_len + tkfont.measure('C')
                    rate_len = rate_len + tksubfont.measure(reactant.formula)
                    if reactant.index == int(reactant.index):
                        index = int(reactant.index)
                    else:
                        index = reactant.index

                    if index <> 1.:
                        rate_len = rate_len + tksuperfont.measure(
                            str(index) + ' ')
                    unitindex = unitindex + reactant.index

            lam_len = tkfont.measure(u'\u03BB')
            lam_len = lam_len + tksubfont.measure(str(reaction.number) + ',')
            lam_len = lam_len + tksubfont.measure(str(10))
            lam_len = lam_len + tkfont.measure(' = ' + str(1000) + ' ')

            if unitindex == int(unitindex): unitindex = int(unitindex)
            if (unitindex - 1) != 0:
                if (unitindex - 1) != 1:
                    lam_len = lam_len + tkfont.measure('(' + self.concunit +
                                                       ')')
                    lam_len = lam_len + tksuperfont.measure(
                        str(-(unitindex - 1)))
                else:
                    lam_len = lam_len + tkfont.measure(self.concunit)
            lam_len = lam_len + tkfont.measure(self.timeunit)
            lam_len = lam_len + tksuperfont.measure('-1')

            if self.rate_max < rate_len: self.rate_max = rate_len
            if self.value_max < lam_len: self.value_max = lam_len
    def __init__(self, master, system):
        """Constructor method.  Makes the GUI using the list of "Layer" objects
        "layers." """

        self.master = master
        self.version = system.version
        self.fonttype = system.fonttype
        self.superfont = get_superfont(self.fonttype)
        self.tframe = Frame(master.tframe)
        self.frame = Frame(master.frame)
        self.bframe = Frame(master.bframe)
        self.bgcolor = self.frame.cget('bg')
        self.top = None

        self.chemicals = system.chemicals
        self.layers = system.layers
        self.sorptions = system.sorptions
        self.matrices = system.matrices
        self.dep = system.dep

        self.CSTR_flag = 0
        if system.dep == 'Deposition':
            matrix = system.matrices[system.layers[0].type_index]
            for chemical in self.chemicals:
                for component in matrix.components:
                    if system.sorptions[component.name][
                            chemical.
                            name].isotherm == 'Freundlich' or system.sorptions[
                                component.name][
                                    chemical.name].isotherm == 'Langmuir':
                        self.CSTR_flag = 1
                    elif system.sorptions[component.name][
                            chemical.name].kinetic == 'Transient':
                        self.CSTR_flag = 1

        self.topBCtypes = [
            'Fixed Concentration', 'Mass transfer', 'Finite mixed water column'
        ]
        self.botBCtypes = [
            'Fixed Concentration', 'Flux-matching', 'Zero Gradient'
        ]

        if system.adv == 'Steady flow' or system.adv == 'Tidal oscillation':
            self.U = system.Vdar
        else:
            self.U = 0

        self.concunit = system.concunit
        self.lengthunit = system.lengthunit
        self.timeunit = system.timeunit

        try:
            self.bltype = system.bltype
            self.blcoefs = system.blcoefs
        except:
            self.bltype = 'River'
            self.blcoefs = {}
            self.blcoefs['vx'] = 1.
            self.blcoefs['n'] = 0.02
            self.blcoefs['hriver'] = 5.
            self.blcoefs['rh'] = 5.
            self.blcoefs['nu'] = 1e-6

            self.blcoefs['rhoair'] = 1.
            self.blcoefs['rhowater'] = 1000.
            self.blcoefs['vwind'] = 5.
            self.blcoefs['hlake'] = 10.
            self.blcoefs['llake'] = 1000.

        try:
            self.taucoefs = system.taucoefs
        except:
            self.taucoefs = {}
            self.taucoefs['Q'] = 1.
            self.taucoefs['V'] = 100.
            self.taucoefs['h'] = 1.
            self.taucoefs['DOC'] = 0.
            self.taucoefs['Qevap'] = 0.
            self.taucoefs['Decay'] = 'None'
            self.taucoefs['Evap'] = 'None'

        if system.ICs == None:
            self.ICs = {}
            for layer in system.layers:
                self.ICs[layer.name] = {}
                for chemical in self.chemicals:
                    self.ICs[layer.name][chemical.name] = IC(
                        layer.name, chemical.name)
        else:
            self.ICs = system.ICs

        if system.BCs == None:
            self.BCs = {}
            self.topBCtype = StringVar(value=self.topBCtypes[0])
            self.botBCtype = StringVar(value=self.topBCtypes[0])
            for chemical in self.chemicals:
                self.BCs[chemical.name] = BC(chemical.name, chemical.soluable)
        else:
            self.BCs = system.BCs
            self.topBCtype = StringVar(value=system.topBCtype)
            self.botBCtype = StringVar(value=system.botBCtype)

        self.lengthunits = system.lengthunits
        self.concunits = system.concunits
        self.timeunits = system.timeunits
        self.diffunits = system.diffunits

        self.lengthunit = system.lengthunit
        self.concunit = system.concunit
        self.timeunit = system.timeunit
        self.diffunit = system.diffunit

        self.diff_factor = 1.
        self.k_factor = 1.
        self.flux_factor = 0.001

        if self.lengthunit == self.lengthunits[0]:
            self.diff_factor = self.diff_factor * (10000**2)
            self.k_factor = self.k_factor * 10000
            self.flux_factor = self.flux_factor / (10000**2)
        elif self.lengthunit == self.lengthunits[2]:
            self.diff_factor = self.diff_factor / (100**2)
            self.k_factor = self.k_factor / 100
            self.flux_factor = self.flux_factor * (100**2)

        if self.diffunit == system.diffunits[0]:
            if self.timeunit == self.timeunits[1]:
                self.diff_factor = self.diff_factor * 60
            elif self.timeunit == self.timeunits[2]:
                self.diff_factor = self.diff_factor * 60 * 60
            elif self.timeunit == self.timeunits[3]:
                self.diff_factor = self.diff_factor * 60 * 60 * 24
            elif self.timeunit == self.timeunits[4]:
                self.diff_factor = self.diff_factor * 60 * 60 * 24 * 365.25
        else:
            if self.timeunit == self.timeunits[0]:
                self.diff_factor = self.diff_factor / 365.25 / 24 / 60 / 60
            elif self.timeunit == self.timeunits[1]:
                self.diff_factor = self.diff_factor / 365.25 / 24 / 60
            elif self.timeunit == self.timeunits[2]:
                self.diff_factor = self.diff_factor / 365.25 / 24
            elif self.timeunit == self.timeunits[3]:
                self.diff_factor = self.diff_factor / 365.25
Beispiel #30
0
    def __init__(self, master, system, chemical, chemicals, database,
                 editflag):
        """Constructor method.  Defines the parameters to be obtained in this window."""

        self.master = master
        self.fonttype = system.fonttype
        self.version = system.version
        self.superfont = get_superfont(self.fonttype)  #superscript font
        self.frame = Frame(master.frame)
        self.tframe = Frame(master.tframe)
        self.bframe = Frame(master.bframe)
        self.system = system
        self.database = database
        self.top = None  #flag for existence of toplevel#
        self.tkfont = tkFont.Font(font=system.fonttype)

        self.soluableflag = chemical.soluable
        self.editflag = editflag
        self.cancelflag = 0
        self.chemicals = chemicals
        self.diffunit = system.diffunit
        self.diffunits = system.diffunits

        if self.soluableflag == 1:
            self.database = database
            self.chemical = chemical

            self.name = StringVar(value='')
            self.formula = StringVar(value='')
            self.MW = DoubleVar(value=0)
            self.temp = DoubleVar(value=0)
            self.Dw = DoubleVar(value=0)
            self.Ref = StringVar(value='')
            self.Koc = DoubleVar(value=0)
            self.Kdoc = DoubleVar(value=0)
            self.Kf = DoubleVar(value=0)
            self.N = DoubleVar(value=0)

            if editflag == 1:  #Detemine whether the chemical is added or edited

                self.name.set(self.chemical.name)
                self.formula.set(self.chemical.formula)
                self.MW.set(self.chemical.MW)
                self.temp.set(self.chemical.temp)
                self.Dw.set(self.chemical.Dw)
                self.Koc.set(self.chemical.Koc)
                self.Kdoc.set(self.chemical.Kdoc)
                self.Ref.set(self.chemical.Ref)
                self.Kf.set(self.chemical.Kf)
                self.N.set(self.chemical.N)
        else:
            self.name = StringVar(value=' ')
            self.formula = StringVar(value=' ')
            self.MW = DoubleVar(value=100)
            self.temp = DoubleVar(value=0)
            self.Dw = DoubleVar(value=0)
            self.Koc = DoubleVar(value=0)
            self.Kdoc = DoubleVar(value=0)
            self.Kf = DoubleVar(value=0)
            self.N = DoubleVar(value=0)

            if editflag == 1:  #Detemine whether the chemical is added or edited
                self.name.set(chemical.name)