def __init__(self, zone, value, rate=None): """constructor with : - zone : Mesh support - value : a PhysicalQuantity or a list of couple (PhysicalQuantity,species) or a ChemicalState - OPTIONAL : --> rate : FlowRate """ memberShip(zone, [CartesianMesh]) self.zone = zone self.value_species = None self.value_property = None self.value = None if value: memberShip(value,[PhysicalQuantity,ChemicalState]) if (isInstance(value, PhysicalQuantity) or type(value) is types.ListType): self.value_species,self.value_property = createList(value, PhysicalQuantity) pass else: self.value = value pass pass if rate: memberShip(value, Flowrate) self.rate = rate return
def __init__(self, zone, value=None): """ constructor with : - zone : object CartesianMesh - OPTINAL : --> value : a PhysicalQuantity or a list of couple (PhysicalQuantity,species) or a ChemicalState """ if type(zone) is types.ListType: verifyClassList(zone,[CartesianMesh]) pass else: memberShip(zone,[CartesianMesh]) pass self.zone = zone self.value_species = None self.value_property = None self.value = None if value: memberShip(value,[PhysicalQuantity,ChemicalState]) if (isInstance(value, PhysicalQuantity) or type(value) is types.ListType): self.value_species, self.value_property = createList(value, PhysicalQuantity) pass else: self.value = value pass pass
def __init__(self, boundary, kind, value, bcdict, porosity=None, description=None): """Boundary condition initialisation with : - one boundary - a boundary condition type. We verify that it's a key of bcdict dictionnary - a boundary condition value. Value depend of boundary condition type. -bcdict : a dictionnary with key = type of boundary condition and value = Possible class of boundary condition value """ self.value_species = None memberShip(boundary.support, [CartesianMesh, Body]) # verifyClass(boundary,[CartesianMesh,Body]) self.boundary = boundary if type(kind) != StringType: raise TypeError(" type should be a string") if kind not in list(bcdict.keys()): raise Exception(" check the boundary condition type ") self.type = kind value = toList(value) for val in value: if type(val) is TupleType: checked = val[0] for i in range(1, len(val)): memberShip(val[i], Species) pass pass else: checked = val pass for definedtype in bcdict: if kind == definedtype: memberShip(checked, bcdict[kind]) pass pass pass if not self.value_species: from PhysicalQuantities import PhysicalQuantity from species import createList print(value) self.value_species, self.value_property = createList( value, PhysicalQuantity) pass if description == None: self.description = "" pass else: self.description = description pass return
def setRetardationFactor(self, retardationFactor): """set retardation factor""" retardationFactor_species, retardationFactor_property = createList(retardationFactor, RetardationFactor) if not self.retardationFactor_species: self.retardationFactor_species = [] pass if not self.retardationFactor_property: self.retardationFactor_property = [] pass self.retardationFactor_species += retardationFactor_species self.retardationFactor_property += retardationFactor_property
def setRetardationFactor(self, retardationFactor): """set retardation factor""" retardationFactor_species, retardationFactor_property = createList( retardationFactor, RetardationFactor) if not self.retardationFactor_species: self.retardationFactor_species = [] pass if not self.retardationFactor_property: self.retardationFactor_property = [] pass self.retardationFactor_species += retardationFactor_species self.retardationFactor_property += retardationFactor_property
def __init__(self, boundary, kind, value, bcdict, porosity = None, description = None): """Boundary condition initialisation with : - one boundary - a boundary condition type. We verify that it's a key of bcdict dictionnary - a boundary condition value. Value depend of boundary condition type. -bcdict : a dictionnary with key = type of boundary condition and value = Possible class of boundary condition value """ self.value_species =None memberShip(boundary.support,[CartesianMesh, Body]) # verifyClass(boundary,[CartesianMesh,Body]) self.boundary = boundary if type(kind) != StringType: raise TypeError(" type should be a string") if kind not in list(bcdict.keys()): raise Exception(" check the boundary condition type ") self.type = kind value = toList(value) for val in value: if type(val) is TupleType: checked = val[0] for i in range(1,len(val)): from datamodel import Species memberShip(val[i], Species) pass pass else: checked = val pass for definedtype in bcdict: if kind == definedtype: memberShip(checked, bcdict[kind]) pass pass pass if not self.value_species: from PhysicalQuantities import PhysicalQuantity from species import createList print(value) self.value_species, self.value_property = createList(value, PhysicalQuantity) pass if description == None: self.description = "" pass else: self.description = description pass return
def _associateZoneValue(zone,value,some_classes): zones=toList(zone) verifyClassList(zones,[CartesianMesh]) value = toList(value) for val in value: if type(val) is TupleType: from datamodel import Species memberShip(val[0], some_classes) memberShip(val[1], Species) pass else: memberShip(val, some_classes) pass pass from datamodel import createList from datamodel import PhysicalQuantity value_species, value_property = createList(value, PhysicalQuantity) return value_species, value_property
def _associateZoneValue(zone, value, some_classes): zones = toList(zone) verifyClassList(zones, [CartesianMesh]) value = toList(value) for val in value: if type(val) is TupleType: from datamodel import Species memberShip(val[0], some_classes) memberShip(val[1], Species) pass else: memberShip(val, some_classes) pass pass from datamodel import createList from datamodel import PhysicalQuantity value_species, value_property = createList(value, PhysicalQuantity) return value_species, value_property
def changeProperty(self, PQ, value): """ Change a material property value """ if ( not issubclass(PQ, PhysicalLaw) + issubclass(PQ, PQuantity) + issubclass(PQ, AquiferProperty) + issubclass(PQ, SolidProperty) ): raise Exception("problem with class membership") key = PQ.__name__ # print "dbg material changeProperty",PQ.__name__ key = key[0].lower() + key[1:] # print " dbg material key",key if hasattr(self, key): # property of the material only setattr(self, key, value) elif hasattr(self, key + "_species") and hasattr(self, key + "_property"): if not value: setattr(self, key + "_species", None) setattr(self, key + "_property", None) return # property depending on the material and species # print 'Classe :',PQ.__name__ spec_list, prop_list = createList(value, PQ) spec_aux, prop_aux = getattr(self, key + "_species"), getattr(self, key + "_property") if not spec_aux: spec_aux = [] pass if not prop_aux: prop_aux = [] pass if len(spec_list) == 1: if spec_list[0] != "ALL": raise Exception spec_aux, prop_aux = spec_list, prop_list pass else: if len(spec_aux) == 1: if spec_aux[0] != "ALL": raise Exception for spe in spec_list: indexlist = spec_list.index(spe) prop = prop_list[indexlist] if spe in spec_aux: indexaux = spec_aux.index(spe) prop_aux[indexaux] = prop pass else: spec_aux.append(spe) prop_aux.append(prop) pass pass pass setattr(self, key + "_species", spec_aux) setattr(self, key + "_property", prop_aux) ## print key+'_species :',spec_aux ## print key+'_property:',prop_aux pass else: raise Exception return
def __init__(self, boundary, btype, value = None, massTCoef = None, velocity = None, flowRate = None, porosity = None, timeVariation = None, description = None): """ Constructor with : - boundary : a mesh part element of type Cartesian or Unstructured ( made of bodies) - btype : is a string and should be "Dirichlet", "Flux", "Mixed", "Neumann" For a "symmetry", a Neumann boundary condition with g = 0 must be specified - OPTIONAL : --> value : a PhysicalQuantity or a list of tuples (PhysicalQuantity,species) or a ChemicalState --> massTCoef : float : mass transfer coefficient or set to zero --> velocity : object Velocity --> porosity : a scalar. --> flowRate : a Flowrate, see PhysicalQuantities --> timeVariation : a list of tuples [(time,chemical state)] , [(time,(list of species and eventually temperature))]; the temperature can also be introduced through a file. -- description a string which will be eventually set as a support for the model comprehension """ bcDico = makeDico(Dirichlet = [ChemicalState, Head, Displacement, NormalForce],\ Flux = [ChemicalState, HeadGradient],\ Neumann = [ChemicalState, HeadGradient]) CommonBoundaryCondition.__init__(self,boundary, btype, value, bcDico, description) # print "dbg commonmodel CommonBoundaryCondition1" if type(boundary) is types.ListType: # print "type of boundary is list type " #raw_input("type of boundary is list type ") verifyClassList(boundary,[ CartesianMesh, Body]) pass else: memberShip(boundary,[ CartesianMesh, Body]) #raw_input("membership ") pass #raw_input("dbg commonmodel CommonBoundaryCondition2") self.boundary = boundary if type(btype) != types.StringType: raise TypeError, " problem on the definition of the boundary type " if btype.lower() not in ["dirichlet","symmetry","flux","mixed","neumann","noflux"]: raise Exception, " check the boundary condition kind" self.btype = btype self.chemicalStateValue = None self.headValue = None self.massTCoef = 0. self.value_species = None self.value_property = None self.value = None # # the next ones are linked to a well sim. # self.enthalpyBoundaryCondition = None self.wellMassFlowBoundaryCondition = None self.wellPressureBoundaryCondition = None # # We treat B.C. # by default, a chemical state is introduced # and in the case of a transient flow, eventually a list # made of a chemical state, a displacement, a head. # if type(value) is types.ListType: # # useful for debugging # #for i in value: # print "dbg commonmodel",type(i) # pass verifyClassList(value, [ Head, ChemicalState, Displacement, NormalForce, TupleType]) for bc in value: if isinstance(bc, Head): self.headValue = bc # it should be the charge pass elif isinstance(bc, NormalForce): self.normalForceValue = bc # it should be NormalForce pass elif isinstance(bc, Displacement): self.displacementValue = bc # it should be Displacement pass elif isinstance(bc, ChemicalState): self.value = bc self.chemicalStateValue = bc # it should be ChemicalState pass elif bc[0].lower() =="enthalpy": # it can also be an enthalpy in the # case of a well # if type(bc[1]) == types.StringType: self.enthalpyBoundaryCondition = refindall(recompile(r'([xyzXYZ0-9.*/+-])'),bc[1]) pass elif type(bc[1]) in [types.FloatType,types.IntType]: self.enthalpyBoundaryCondition = bc[1] pass elif bc[0].lower() =="wellpressure": # it can also be the pressure in the # case of a well # if type(bc[1]) == types.StringType: self.wellPressureBoundaryCondition = refindall(recompile(r'([xyzXYZ0-9.*/+-])'),bc[1]) pass elif type(bc[1]) in [types.FloatType,types.IntType]: self.wellPressureBoundaryCondition = bc[1] #print("commonmodel well pressure debug yes\n") #raw_input() pass pass elif bc[0].lower() =="wellmassflow": # it can also be the mass flow in the # case of a well # if type(bc[1]) == types.StringType: self.wellMassFlowBoundaryCondition = refindall(recompile(r'([xyzXYZ0-9.*/+-])'),bc[1]) pass elif type(bc[1]) in [types.FloatType,types.IntType]: self.wellMassFlowBoundaryCondition = bc[1] pass pass else: #self.value = bc # it should be chemistry pass pass pass else: memberShip(value,[PhysicalQuantity, ChemicalState, Displacement, NormalForce]) if (isinstance(value, PhysicalQuantity) or type(value) is types.ListType): self.value_species, self.value_property = createList(value, PhysicalQuantity) pass else: self.value = value self.chemicalStateValue = value pass pass print "massTCoef",massTCoef,type(massTCoef) if massTCoef: memberShip(massTCoef,[types.FloatType]) if (type(massTCoef) is types.FloatType): self.massTCoef = massTCoef pass else: self.massTCoef = 0.0 pass print " common model mass transfer coefficient ",self.massTCoef pass if porosity: self.porosity = porosity pass if velocity: memberShip(velocity,Velocity) pass self.velocity = velocity if flowRate: if flowRate.__class__.__name__=="FlowRate": pass else: flowrate = FlowRate(flowrate,"m**3/s") # the flow rate is supposed to be in m**3/s pass self.flowRate = flowRate if timeVariation: if type(timeVariation) != types.ListType: raise typeError, " Time variation should be a list" for item in timeVariation: if type(item[0]) not in [types.FloatType,types.IntType]: raise typeError, "item[@] should be a list" memberShip(item[1],[ChemicalState]) pass pass self.timeVariation = timeVariation return None
def __init__(self, body, value, description = None): """ constructor with : - body : object body or CartesianMesh - value : a PhysicalQuantity, a list of tuples (PhysicalQuantity,species) a ChemicalState or a tuple to introduce a function on a specific variable """ if type(body) is types.ListType: verifyClassList(body,[CartesianMesh]) pass else: memberShip(body,[CartesianMesh, Body]) pass self.zone = body self.body = body self.value_species = None self.value_property = None self.value = None self.headValue = None # # Linked to the treatment of a wellbore # self.enthalpyInitialCondition = None self.wellFeedZoneInitialCondition = None self.temperatureInitialCondition = None self.wellMassFlowInitialCondition = None self.wellPressureInitialCondition = None # if type(value) is types.ListType: for i in value: print ("dbg commonmodel",type(i)) pass verifyClassList(value, [ Head, ChemicalState, Displacement, types.TupleType]) for ic in value: if isinstance(ic, Head): self.headValue = ic # It should be the charge pass elif isinstance(ic, (Displacement, ChemicalState)) : self.value = ic # It should be chemistry or a displacement pass elif isinstance(ic, types.TupleType): #print("debug commonmodel ic %s\n"%(ic[0].lower())) if ic[0].lower() == "enthalpy": # It can also be an enthalpy in the # case of a well if type(ic[1]) == types.StringType: #raw_input("common model debug") self.enthalpyInitialCondition = refindall(recompile(r'([xyzXYZ0-9.*/+-])'), ic[1]) pass pass elif ic[0].lower().replace(" ","") == "feedzoneheatsource": # We introduce here a heat source linked to a feed zone. if type(ic[1]) in [types.TupleType, types.ListType]: # It should be a tuple: position and value of the source term. self.wellFeedZoneInitialCondition = ic[1] pass elif type(ic[1]) is types.StringType: # It should be a tuple: position and value of the source term. self.wellFeedZoneInitialCondition = refindall(recompile(r'([ifelsxyzXYZ0-9.*;()/+-<>=])'), ic[1]) pass #print("in commonmodel ",self.wellFeedZoneInitialCondition) #raw_input() pass elif ic[0].lower() == "temperature": # It should be temperature otherwise a warning # is raised. We extract the formula thanks to != # regular expressions modules. if type(ic[1]) == types.StringType: self.temperatureInitialCondition = refindall(recompile(r'([xyzXYZ0-9.*/+-])'), ic[1]) pass pass elif ic[0].lower().replace(" ","") == "wellmassflow": # It can also be the mass flow in the # case of a well if type(ic[1]) == types.StringType: self.wellMassFlowInitialCondition = refindall(recompile(r'([xyzXYZ0-9.*/+-])'), ic[1]) pass elif type(ic[1]) in [types.FloatType,types.IntType]: self.wellMassFlowInitialCondition = ic[1] pass pass elif ic[0].lower().replace(" ","") == "wellpressure": # It can also be the pressure in the # case of a well if type(ic[1]) == types.StringType: self.wellPressureInitialCondition = refindall(recompile(r'([xyzXYZ0-9.*/+-])'), ic[1]) pass elif type(ic[1]) in [types.FloatType, types.IntType]: self.wellPressureInitialCondition = ic[1] #print("commonmodel well pressure debug yes\n") #raw_input() pass pass else: raise Warning, "check the name of the variable " pass else: if (isinstance(ic, PhysicalQuantity) or type(ic) is types.ListType): self.value_species, self.value_property = createList(ic, PhysicalQuantity) pass else: self.value = ic pass pass pass pass else: memberShip(value,[PhysicalQuantity,ChemicalState]) if (isinstance(value, PhysicalQuantity) or type(value) is types.ListType): self.value_species,self.value_property = createList(value, PhysicalQuantity) pass else: self.value = value pass pass self.description = description return None
def __init__(self, boundary, btype, value = None, massTCoef = None, velocity = None, flowRate = None, porosity = None, timeVariation = None, description = None): """ Constructor with : - boundary : a mesh part element of type Cartesian or Unstructured ( made of bodies) - btype : is a string and should be "Dirichlet", "Flux", "Mixed", "Neumann" For a "symmetry", a Neumann boundary condition with g = 0 must be specified - OPTIONAL : --> value : a PhysicalQuantity or a list of tuples (PhysicalQuantity,species) or a ChemicalState --> massTCoef : float : mass transfer coefficient or set to zero --> velocity : object Velocity --> porosity : a scalar. --> flowRate : a Flowrate, see PhysicalQuantities --> timeVariation : a list of tuples [(time,chemical state)] , [(time,(list of species and eventually temperature))]; the temperature can also be introduced through a file. -- description a string which will be eventually set as a support for the model comprehension """ bcDico = makeDico(Dirichlet = [ChemicalState, Head, Displacement, NormalForce],\ Flux = [ChemicalState, HeadGradient],\ Neumann = [ChemicalState, HeadGradient]) CommonBoundaryCondition.__init__(self,boundary, btype, value, bcDico, description) # print "dbg commonmodel CommonBoundaryCondition1" if type(boundary) is types.ListType: # print "type of boundary is list type " #raw_input("type of boundary is list type ") verifyClassList(boundary,[ CartesianMesh, Body]) pass else: memberShip(boundary,[ CartesianMesh, Body]) #raw_input("membership ") pass #raw_input("dbg commonmodel CommonBoundaryCondition2") self.boundary = boundary if type(btype) != types.StringType: raise TypeError, " problem on the definition of the boundary type " if btype.lower() not in ["dirichlet","symmetry","flux","mixed","neumann","noflux"]: raise Exception, " check the boundary condition kind" self.btype = btype self.chemicalStateValue = None self.headValue = None self.massTCoef = 0. self.value_species = None self.value_property = None self.value = None # # the next ones are linked to a well sim. # self.enthalpyBoundaryCondition = None self.wellMassFlowBoundaryCondition = None self.wellPressureBoundaryCondition = None # # We treat B.C. # by default, a chemical state is introduced # and in the case of a transient flow, eventually a list # made of a chemical state, a displacement, a head. # if type(value) is types.ListType: # # useful for debugging # #for i in value: # print "dbg commonmodel",type(i) # pass verifyClassList(value, [ Head, ChemicalState, Displacement, NormalForce, TupleType]) for bc in value: if isinstance(bc, Head): self.headValue = bc # it should be the charge pass elif isinstance(bc, NormalForce): self.normalForceValue = bc # it should be NormalForce pass elif isinstance(bc, Displacement): self.displacementValue = bc # it should be Displacement pass elif isinstance(bc, ChemicalState): self.value = bc self.chemicalStateValue = bc # it should be ChemicalState pass elif bc[0].lower() == "enthalpy": # it can also be an enthalpy in the # case of a well # if type(bc[1]) == types.StringType: self.enthalpyBoundaryCondition = refindall(recompile(r'([xyzXYZ0-9.*/+-])'),bc[1]) pass elif type(bc[1]) in [types.FloatType,types.IntType]: self.enthalpyBoundaryCondition = bc[1] pass elif bc[0].lower() == "wellpressure": # it can also be the pressure in the # case of a well # if type(bc[1]) == types.StringType: self.wellPressureBoundaryCondition = refindall(recompile(r'([xyzXYZ0-9.*/+-])'),bc[1]) pass elif type(bc[1]) in [types.FloatType,types.IntType]: self.wellPressureBoundaryCondition = bc[1] #print("commonmodel well pressure debug yes\n") #raw_input() pass pass elif bc[0].lower() == "wellmassflow": # it can also be the mass flow in the # case of a well # if type(bc[1]) == types.StringType: self.wellMassFlowBoundaryCondition = refindall(recompile(r'([$mfunction()ifelse{} ><_=xyzXYZ0-9.*/+-])'),bc[1]) pass elif type(bc[1]) in [types.FloatType,types.IntType]: self.wellMassFlowBoundaryCondition = bc[1] pass elif type(bc[1]) is tuple: self.wellMassFlowBoundaryCondition = bc[1] pass pass else: #self.value = bc # it should be chemistry pass pass pass else: memberShip(value,[PhysicalQuantity, ChemicalState, Displacement, NormalForce]) if (isinstance(value, PhysicalQuantity) or type(value) is types.ListType): self.value_species, self.value_property = createList(value, PhysicalQuantity) pass else: self.value = value self.chemicalStateValue = value pass pass print "massTCoef",massTCoef,type(massTCoef) if massTCoef: memberShip(massTCoef,[types.FloatType]) if (type(massTCoef) is types.FloatType): self.massTCoef = massTCoef pass else: self.massTCoef = 0.0 pass print " common model mass transfer coefficient ",self.massTCoef pass if porosity: self.porosity = porosity pass if velocity: memberShip(velocity,Velocity) pass self.velocity = velocity if flowRate: if flowRate.__class__.__name__=="FlowRate": pass else: flowrate = FlowRate(flowrate,"m**3/s") # the flow rate is supposed to be in m**3/s pass self.flowRate = flowRate if timeVariation: if type(timeVariation) != types.ListType: raise typeError, " Time variation should be a list" for item in timeVariation: if type(item[0]) not in [types.FloatType,types.IntType]: raise typeError, "item[@] should be a list" memberShip(item[1],[ChemicalState]) pass pass self.timeVariation = timeVariation return None
def __init__(self, body, value, description = None): """ constructor with : - body : object body or CartesianMesh - value : a PhysicalQuantity, a list of tuples (PhysicalQuantity,species) a ChemicalState or a tuple to introduce a function on a specific variable """ if type(body) is types.ListType: verifyClassList(body,[CartesianMesh]) pass else: memberShip(body,[CartesianMesh, Body]) pass self.zone = body self.body = body self.value_species = None self.value_property = None self.value = None self.enthalpyInitialCondition = None self.headValue = None self.temperatureInitialCondition = None self.wellMassFlowInitialCondition = None self.wellPressureInitialCondition = None if type(value) is types.ListType: for i in value: print ("dbg commonmodel",type(i)) pass verifyClassList(value, [ Head, ChemicalState, Displacement, types.TupleType]) for ic in value: if isinstance(ic, Head): self.headValue = ic # it should be the charge pass elif isinstance(ic, (Displacement,ChemicalState)) : self.value = ic # it should be chemistry or a displacement pass elif isinstance(ic, types.TupleType): #print("debug commonmodel ic %s\n"%(ic[0].lower())) if ic[0].lower() =="temperature": # it should be temperature otherwise a warning # is raised. we extract the formula thanks to != # regular expressions modules. # if type(ic[1]) == types.StringType: self.temperatureInitialCondition = refindall(recompile(r'([xyzXYZ0-9.*/+-])'),ic[1]) pass pass elif ic[0].lower() =="enthalpy": # it can also be an enthalpy in the # case of a well # if type(ic[1]) == types.StringType: #raw_input("common model debug") self.enthalpyInitialCondition = refindall(recompile(r'([xyzXYZ0-9.*/+-])'),ic[1]) pass pass elif ic[0].lower() =="wellpressure": # it can also be the pressure in the # case of a well # if type(ic[1]) == types.StringType: self.wellPressureInitialCondition = refindall(recompile(r'([xyzXYZ0-9.*/+-])'),ic[1]) pass elif type(ic[1]) in [types.FloatType,types.IntType]: self.wellPressureInitialCondition = ic[1] #print("commonmodel well pressure debug yes\n") #raw_input() pass pass elif ic[0].lower() =="wellmassflow": # it can also be the mass flow in the # case of a well # if type(ic[1]) == types.StringType: self.wellMassFlowInitialCondition = refindall(recompile(r'([xyzXYZ0-9.*/+-])'),ic[1]) pass elif type(ic[1]) in [types.FloatType,types.IntType]: self.wellMassFlowInitialCondition = ic[1] pass pass else: raise Warning, "check the name of the vriable " pass else: if (isinstance(ic, PhysicalQuantity) or type(ic) is types.ListType): self.value_species, self.value_property = createList(ic, PhysicalQuantity) pass else: self.value = ic pass pass pass pass else: memberShip(value,[PhysicalQuantity,ChemicalState]) if (isinstance(value, PhysicalQuantity) or type(value) is types.ListType): self.value_species,self.value_property = createList(value, PhysicalQuantity) pass else: self.value = value pass pass self.description = description return None
def changeProperty(self, PQ, value): """ Change a material property value """ if not issubclass(PQ, PhysicalLaw) + issubclass( PQ, PQuantity) + issubclass(PQ, AquiferProperty) + issubclass( PQ, SolidProperty): raise Exception("problem with class membership") key = PQ.__name__ #print "dbg material changeProperty",PQ.__name__ key = key[0].lower() + key[1:] #print " dbg material key",key if hasattr(self, key): # property of the material only setattr(self, key, value) elif hasattr(self, key + '_species') and hasattr( self, key + '_property'): if not value: setattr(self, key + '_species', None) setattr(self, key + '_property', None) return # property depending on the material and species #print 'Classe :',PQ.__name__ spec_list, prop_list = createList(value, PQ) spec_aux,prop_aux=getattr(self,key+'_species'),\ getattr(self,key+'_property') if not spec_aux: spec_aux = [] pass if not prop_aux: prop_aux = [] pass if len(spec_list) == 1: if spec_list[0] != 'ALL': raise Exception spec_aux, prop_aux = spec_list, prop_list pass else: if len(spec_aux) == 1: if spec_aux[0] != 'ALL': raise Exception for spe in spec_list: indexlist = spec_list.index(spe) prop = prop_list[indexlist] if spe in spec_aux: indexaux = spec_aux.index(spe) prop_aux[indexaux] = prop pass else: spec_aux.append(spe) prop_aux.append(prop) pass pass pass setattr(self, key + '_species', spec_aux) setattr(self, key + '_property', prop_aux) ## print key+'_species :',spec_aux ## print key+'_property:',prop_aux pass else: raise Exception return
def __init__(self, boundary, btype, value, bcdict, porosity = None, description = None): """ Boundary condition initialisation with : - one boundary - a boundary condition type. We verify that it's a key of bcdict dictionnary - a boundary condition value. Value depend of boundary condition type. - bcdict : a dictionnary with key = type of boundary condition and value = Possible class of boundary condition value All boundary conditions satisfy that format. It should enable the lecture of hydraulic, mechanical and chemical-transport boundary conditions. Exemple: bcdict = {'Flux': [class chemistry.ChemicalState , class PhysicalQuantities.HeadGradient], 'Dirichlet': [class chemistry.ChemicalState, class PhysicalQuantities.Head,\ class PhysicalQuantities.Displacement, class PhysicalQuantities.NormalForce], 'Neumann': [class chemistry.ChemicalState, class PhysicalQuantities.HeadGradient]} """ self.value = None self.value_species = None #print " here we are 1, bcdict ", bcdict #print " here we are 2, bcdict ", bcdict.keys() #print value #raw_input() #print("dbg bcdict ",list(bcdict.keys())) if isInstance(boundary,[CartesianMesh, Body]): pass else: memberShip(boundary.support,[CartesianMesh, Body]) pass self.boundary = boundary if type(btype) != StringType: raise TypeError(" type should be a string ") if btype not in list(bcdict.keys()): print("bcdict.keys():",list(bcdict.keys())) print("btype : ",btype) raise Exception(" check the boundary condition type ") self.type = btype print("value: ",type(value.__class__.__name__),value.__class__.__name__) #print "dbg bcdict ",bcdict.keys() #raw_input( "valuefffffffff fff") #if value.__class__.__name__ == 'Head': # print "valueeeee Head",value.__class__.__name__ #else: # print "valueeeef",value.__class__.__name__ if isinstance(value,ListType): print(" value is of type ListType") for val in value: if isinstance(val,Displacement): self.value = {"Displacement":val.getValue()} pass elif isinstance(val,NormalForce): if self.value != None: self.value["NormalForce"] = val.getValue() pass else: self.value = {"NormalForce":val.getValue()} pass elif isinstance(value,Head): valeurs=toList (val) for vale in valeurs: if type(val) is TupleType: checked = val[0] for i in range(1,len(val)): memberShip(val[i], Species) pass pass else: checked = val pass pass pass elif isinstance(value,Displacement): print(" value is of type Displacement") self.value = {"Displacement":value.getValue()} pass elif isinstance(value,NormalForce): print(" value is of type NormalForce") if self.value != None: self.value["NormalForce"] = value.getValue() pass else: self.value = {"NormalForce":value.getValue()} pass pass elif isinstance(value,Head): print(" value is of type Head") from datamodel import Species value=toList (value) for val in value: if type(val) is TupleType: checked = val[0] for i in range(1,len(val)): memberShip(val[i], Species) pass pass else: checked = val pass for definedType in bcdict: if btype == definedType: memberShip(checked, bcdict[btype]) #raw_input("here we are") pass pass pass if not self.value_species: from PhysicalQuantities import PhysicalQuantity from species import createList print(value) self.value_species, self.value_property = createList(value, PhysicalQuantity) pass if description == None: self.description = None pass else: self.description = description pass return None
def __init__(self, zone, value,some_classes,some_solid_classes=None): """ Initial condition initialisation with - one or several zones - a value instance of a class defined in some_classes or a list of couple (Value,Species) or a list with a defaut value and couples (Value,Species) for example [c,(c1,species1),(c2,species2)] - some_classes : list of possible classes of value (soluble classes) - some_solid_classes : list of possible classes of value (solid classes) """ zones=toList(zone) #verifyZones(zones) self.zone = zone if some_solid_classes: all_classes = some_classes + some_solid_classes pass else: all_classes = some_classes pass val_solub=[] val_solid=[] self.value_species=[] self.value_property=[] self.value_solid_species=[] self.value_solid_property=[] value = toList(value) for val in value: solubOK = 0 if type(val) is TupleType: from datamodel import Species memberShip(val[0], all_classes) memberShip(val[1], Species) for sc in some_classes: if isInstance(val[0], sc): val_solub.append(val) solub0K = 1 break pass if some_solid_classes and not solubOK: for sc in some_solid_classes: if isInstance(val[0], sc): val_solid.append(val) break pass pass pass else: memberShip(val, all_classes) for sc in some_classes: if isInstance(val, sc): val_solub.append(val) solub0K = 1 break if some_solid_classes and not solubOK: for sc in some_solid_classes: if isInstance(val, sc): val_solid.append(val) break pass pass pass if val_solub: from datamodel import createList from datamodel import PhysicalQuantity self.value_species, self.value_property = createList(val_solub, PhysicalQuantity) pass if val_solid: from datamodel import createList from datamodel import PhysicalQuantity self.value_solid_species, self.value_solid_property = createList(val_solid, PhysicalQuantity) pass return
def __init__(self, boundary, btype, value, bcdict, porosity=None, description=None): """ Boundary condition initialisation with : - one boundary - a boundary condition type. We verify that it's a key of bcdict dictionnary - a boundary condition value. Value depend of boundary condition type. - bcdict : a dictionnary with key = type of boundary condition and value = Possible class of boundary condition value: As an example, we can have for bcdict.keys() : ['Flux', 'Dirichlet', 'Neumann'] All boundary conditions satisfy that format. It should enable the lecture of hydraulic, mechanical and chemical-transport boundary conditions. Exemple: bcdict = {'Flux': [class chemistry.ChemicalState , class PhysicalQuantities.HeadGradient], 'Dirichlet': [class chemistry.ChemicalState, class PhysicalQuantities.Head, class PhysicalQuantities.Pressure,\ class PhysicalQuantities.Displacement, class PhysicalQuantities.NormalForce], 'Neumann': [class chemistry.ChemicalState, class PhysicalQuantities.HeadGradient]} """ self.value = None self.value_species = None #print (" here we are 1, bcdict ", bcdict) #print (" here we are 2, bcdict ", bcdict.keys()) #print value #raw_input() #print("dbg bcdict ",list(bcdict.keys())) if isInstance(boundary, [CartesianMesh, Body]): pass else: memberShip(boundary.support, [CartesianMesh, Body]) pass self.boundary = boundary if type(btype) != StringType: raise TypeError(" type should be a string ") if btype not in list(bcdict.keys()): print("bcdict.keys() are:", list(bcdict.keys())) print("and btype %s is not in bdict: " % (btype)) raise Exception(" check the boundary condition type ") self.type = btype print("debug commonproblem CommonBoundaryCondition value: ", type(value.__class__.__name__), value.__class__.__name__) #print "dbg bcdict ",bcdict.keys() #raw_input( "valuefffffffff fff") #if value.__class__.__name__ == 'Head': # print "valueeeee Head",value.__class__.__name__ #else: # print "valueeeef",value.__class__.__name__ if isinstance(value, (ListType, TupleType)): #print(" debug commonproblem CommonBoundaryCondition, value is of type ListType", type(value), value) for val in value: print( "debug commonproblem CommonBoundaryCondition, debug val: ", val) if isinstance(val, Displacement): self.value = {"Displacement": val.getValue()} pass elif isinstance(val, NormalForce): if self.value != None: self.value["NormalForce"] = val.getValue() pass else: self.value = {"NormalForce": val.getValue()} pass elif isinstance(val, (Head, Pressure)): valeurs = toList(val) for vale in valeurs: if type(val) is TupleType: checked = val[0] for i in range(1, len(val)): memberShip(val[i], Species) pass pass else: checked = val pass pass print("dbg commonproblem %s\n" % (val.__class__.__name__.lower())) if self.value != None: self.value[ val.__class__.__name__.lower()] = val.getValue() else: self.value = { val.__class__.__name__.lower(): val.getValue() } pass elif isinstance(val, Temperature): if self.value != None: self.value[ val.__class__.__name__.lower()] = val.getValue() else: self.value = { val.__class__.__name__.lower(): val.getValue() } pass pass print("debug commonproblem CommonBoundaryCondition: ", self.value) pass elif isinstance(value, Displacement): #print("debug commonproblem value is of type Displacement") self.value = {"Displacement": value.getValue()} pass elif isinstance(value, NormalForce): #print("debug commonproblem value is of type NormalForce") if self.value != None: self.value["NormalForce"] = value.getValue() pass else: self.value = {"NormalForce": value.getValue()} pass pass elif isinstance(value, (Head, Pressure)): print("debug commonproblem value is of type Head or Pressure") from datamodel import Species value = toList(value) #print("debug commonproblem value is of type Head or Pressure: ", value) #print("debug commonproblem value is of type Head or Pressure: ", bcdict) for val in value: if type(val) is TupleType: checked = val[0] for i in range(1, len(val)): memberShip(val[i], Species) pass pass else: checked = val pass for definedType in bcdict: if btype == definedType: memberShip(checked, bcdict[btype]) #raw_input("here we are") pass pass pass if not self.value_species: from PhysicalQuantities import PhysicalQuantity from species import createList print(value) self.value_species, self.value_property = createList( value, PhysicalQuantity) pass self.value = { value[0].__class__.__name__.lower(): value[0].getValue() } #print(" dbg commonproblem: valeur de self.value",self.value) #raw_input("dbg commonproblem: CommonBoundaryCondition") if description == None: self.description = None pass else: self.description = description pass return None
def __init__(self, zone, value, some_classes, some_solid_classes=None): """ Initial condition initialisation with - one or several zones - a value instance of a class defined in some_classes or a list of couple (Value,Species) or a list with a defaut value and couples (Value,Species) for example [c,(c1,species1),(c2,species2)] - some_classes : list of possible classes of value (soluble classes) - some_solid_classes : list of possible classes of value (solid classes) """ zones = toList(zone) #verifyZones(zones) self.zone = zone if some_solid_classes: all_classes = some_classes + some_solid_classes pass else: all_classes = some_classes pass val_solub = [] val_solid = [] self.value_species = [] self.value_property = [] self.value_solid_species = [] self.value_solid_property = [] value = toList(value) for val in value: solubOK = 0 if type(val) is TupleType: from datamodel import Species memberShip(val[0], all_classes) memberShip(val[1], Species) for sc in some_classes: if isInstance(val[0], sc): val_solub.append(val) solub0K = 1 break pass if some_solid_classes and not solubOK: for sc in some_solid_classes: if isInstance(val[0], sc): val_solid.append(val) break pass pass pass else: memberShip(val, all_classes) for sc in some_classes: if isInstance(val, sc): val_solub.append(val) solub0K = 1 break if some_solid_classes and not solubOK: for sc in some_solid_classes: if isInstance(val, sc): val_solid.append(val) break pass pass pass if val_solub: from datamodel import createList from datamodel import PhysicalQuantity self.value_species, self.value_property = createList( val_solub, PhysicalQuantity) pass if val_solid: from datamodel import createList from datamodel import PhysicalQuantity self.value_solid_species, self.value_solid_property = createList( val_solid, PhysicalQuantity) pass return