Beispiel #1
0
    def __init__(self,
                 boundary,
                 btype,
                 value,
                 porosity=None,
                 description=None):
        """Boundary condition initialisation with :
        - one or several boundaries (object Body or StructuredMesh
          or list of Supports)
        - a boundary condition type.
          It can be Dirichlet,Neumann and in the future Flux
        - a boundary condition value. Value depends of boundary condition type.
          If Dirichlet, value can be Head, Pressure or SaturationLevel.
          If Neumann, value can be HeadGradient or PressureGradient.
          If Flux, value can be HydraulicFlux.
        """
        #print("b",boundary)
        #print("k",btype)
        #print("v",value)

        boundaryConditionDico = makeDico(Dirichlet=[Head, Pressure, SaturationLevel],\
                                         Neumann=[HeadGradient, PressureGradient],\
                                         Flux=[HydraulicFlux])

        CommonBoundaryCondition.__init__(self, boundary, btype, value,
                                         boundaryConditionDico, porosity,
                                         description)
        return None
Beispiel #2
0
    def __init__(self,
                 boundary,
                 btype,
                 value,
                 porosity=None,
                 description=None):
        """Boundary condition initialisation with :
        - one or several boundary(ies) (object Region). The objet is a region in order to be able to treat several materials
        - a boundary condition type.
          It can be:
          
            a displacement
            a normal force ( or a pressure)
            In the case of a pressure, the surface of the boundary is retrieved to derive the normal force
            
        - A boundary condition value. Value depends of boundary condition type.
        """
        print("b", boundary, boundary.__class__.__name__)
        print("k", btype)
        print("v", value)

        boundaryConditionDico = makeDico(
            Dirichlet=[Displacement, NormalForce, Pressure])

        CommonBoundaryCondition.__init__(self, boundary, btype, value,
                                         boundaryConditionDico, porosity,
                                         description)
        return None
 def __init__(self, boundary, type,value, description = None):
     """Boundary condition initialisation with :
     - one or several boundaries 
     - a boundary condition type.
       It can be Dirichlet,Neumann,Mixed or Flux
     - a boundary condition value. Value depend of boundary condition type.
       If Dirichlet, value can be Pressure.
       If Neumann, value can be PressureGradient.
       If Flux, value can be HydraulicFlux.
       If Mixed, value can be PressureMixed.
     """
     from datamodel import Pressure, PressureGradient, PressureMixed
     from datamodel import HydraulicFlux
     bcdict=makeDico(Dirichlet=[Pressure],Neumann=[PressureGradient],\
                     Mixed=[PressureMixed],Flux=[HydraulicFlux])
     CommonBoundaryCondition.__init__(self, boundary, type, value, bcdict, description)
 def __init__(self, boundary, type, value, description = None):
     """Boundary condition initialisation with :
     - one or several boundaries (object Support or StructuredMesh
       or list of Supports)
     - a boundary condition type.
       It can be Dirichlet,Neumann or Flux
     - a boundary condition value. Value depend of boundary condition type.
       If Dirichlet, value can be Head, Pressure or SaturationDegree.
       If Neumann, value can be HeadGradient or PressureGradient.
       If Flux, value can be HydraulicFlux.
     """
     bcdict = makeDico (Dirichlet=[Head,Pressure,SaturationDegree],\
                        Neumann=[HeadGradient,PressureGradient],\
                        Flux=[HydraulicFlux])
     CommonBoundaryCondition.__init__(self,boundary, type, value, bcdict, description)
     return
Beispiel #5
0
 def __init__(self, boundary, type, value, description=None):
     """Boundary condition initialisation with :
     - one or several boundaries (object Support or StructuredMesh
       or list of Supports)
     - a boundary condition type.
       It can be Dirichlet,Neumann or Flux
     - a boundary condition value. Value depend of boundary condition type.
       If Dirichlet, value can be Head, Pressure or SaturationDegree.
       If Neumann, value can be HeadGradient or PressureGradient.
       If Flux, value can be HydraulicFlux.
     """
     bcdict = makeDico (Dirichlet=[Head,Pressure,SaturationDegree],\
                        Neumann=[HeadGradient,PressureGradient],\
                        Flux=[HydraulicFlux])
     CommonBoundaryCondition.__init__(self, boundary, type, value, bcdict,
                                      description)
     return
Beispiel #6
0
 def __init__(self, boundary, type, value, description=None):
     """Boundary condition initialisation with :
     - one or several boundaries 
     - a boundary condition type.
       It can be Dirichlet, Neumann, Mixed or Flux.
     - a boundary condition value. Value depend of boundary condition type.
       If Dirichlet, value can be Pressure.
       If Neumann, value can be PressureGradient.
       If Flux, value can be HydraulicFlux.
       If Mixed, value can be PressureMixed.
     """
     from datamodel import Pressure, PressureGradient, PressureMixed
     from datamodel import HydraulicFlux
     bcdict = makeDico(Dirichlet=[Head, Pressure, Temperature], Neumann=[PressureGradient],\
                      Mixed=[PressureMixed], Flux=[HydraulicFlux])
     CommonBoundaryCondition.__init__(self, boundary, type, value, bcdict,
                                      description)
Beispiel #7
0
 def __init__(self, boundary, btype, value, porosity = None, description = None):
     """Boundary condition initialisation with :
     - one or several boundaries (object Body or StructuredMesh
       or list of Supports)
     - a boundary condition type.
       It can be Dirichlet,Neumann and in the future Flux
     - a boundary condition value. Value depends of boundary condition type.
       If Dirichlet, value can be Head, Pressure or SaturationLevel.
       If Neumann, value can be HeadGradient or PressureGradient.
       If Flux, value can be HydraulicFlux.
     """
     print("b",boundary)
     print("k",btype)
     print("v",value)
     
     boundaryConditionDico = makeDico(Dirichlet=[Head,Pressure,SaturationLevel],\
                                      Neumann=[HeadGradient,PressureGradient],\
                                      Flux=[HydraulicFlux])
                     
     CommonBoundaryCondition.__init__(self,boundary, btype, value, boundaryConditionDico, porosity, description)
     return None
Beispiel #8
0
 def __init__(self, boundary, btype, value, porosity = None, description = None):
     """Boundary condition initialisation with :
     - one or several boundary(ies) (object (Body) Region). The objet is a region in order to be able to treat several materials
     - a boundary condition type.
       It can be:
       
         a displacement
         a normal force ( or a pressure)
         In the case of a pressure, the surface of the boundary is retrieved to derive the normal force
         
     - A boundary condition value. Value depends of boundary condition type.
     """
     print("b",boundary,boundary.__class__.__name__)
     print("k",btype)
     print("v",value)
     
     boundaryConditionDico = makeDico(Dirichlet=[Displacement, NormalForce, Pressure, ChemicalState])
     #print boundaryConditionDico.keys()
     #raw_input()
     CommonBoundaryCondition.__init__(self, boundary, btype, value, boundaryConditionDico, description)
     BoundaryCondition.porosity = porosity
     ok = 0
     for val in value:
         if val.__class__.__name__ == "ChemicalState":
             ok = 1
             self.chemicalState = val
             break
         pass
     if ok == 0:
         raise Warning(" the association of a chemical state to a boundary is mandatory ")
     ok = 0
     for val in value:
         if val.__class__.__name__ in ["Displacement","NormalForce"]:
             ok = 1
             self.value = val
             break
         pass
     if ok == 0:
         raise Warning(" check the definition of boundary conditions")
     return None
Beispiel #9
0
    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
Beispiel #10
0
    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