Exemplo n.º 1
0
    def __init__(self, domain=None, value=None):
        """
        domain can be a region of the domain, it could also be a simple body associated to .
        """
        memberShip(domain.support, [CartesianMesh, Body])
        self.domain = domain

        #        if domain !=None:
        #            if isinstance(domain,Region):
        #                memberShip(domain.support,[CartesianMesh, Body])
        #            elif isinstance(domain,Body):
        #                pass
        #            elif isinstance(domain,CartesianMesh):
        #                pass
        #        self.domain = domain
        #
        #
        #
        print("dbg CommonInitialCondition", value)
        if type(value) == None:
            self.value = Head(0.0, "m")
        elif isinstance(value, Head):
            self.value = value
        else:
            raise Exception(" to modify, the pressure must be scaled ")
Exemplo n.º 2
0
    def __init__(self, domain = None, value = None):
        """
        domain can be a region of the domain, it could also be a simple body associated to .
        """
        memberShip(domain.support,[CartesianMesh, Body])
        self.domain = domain
        
#        if domain !=None:
#            if isinstance(domain,Region):
#                memberShip(domain.support,[CartesianMesh, Body])
#            elif isinstance(domain,Body):
#                pass
#            elif isinstance(domain,CartesianMesh):
#                pass
#        self.domain = domain
        #
        #
        #
        print("dbg CommonInitialCondition",value)
        if type(value) == None:
            self.value = Head(0.0,"m")
        elif isinstance(value,Head):
            self.value = value
        else:
            raise Exception(" to modify, the pressure must be scaled ")
Exemplo n.º 3
0
class CommonInitialCondition_old:
    """
    Common InitialCondition definition. 
    It means we can use that class for any kind of problem, hydraulic, chemical/transport ...
    """    
    def __init__(self, domain = None, value = None):
        """
        domain can be a region of the domain, it could also be a simple body associated to .
        """
        memberShip(domain.support,[CartesianMesh, Body])
        self.domain = domain
        
#        if domain !=None:
#            if isinstance(domain,Region):
#                memberShip(domain.support,[CartesianMesh, Body])
#            elif isinstance(domain,Body):
#                pass
#            elif isinstance(domain,CartesianMesh):
#                pass
#        self.domain = domain
        #
        #
        #
        print("dbg CommonInitialCondition",value)
        if type(value) == None:
            self.value = Head(0.0,"m")
        elif isinstance(value,Head):
            self.value = value
        else:
            raise Exception(" to modify, the pressure must be scaled ")

    def getDomain(self):
        """get initial conditions  zones"""
        return self.domain

    def getRegion(self):
        """get initial conditions  zones"""
        return self.domain

    def getSupport(self):
        """get initial conditions  zones"""
        dir(self.domain)
        return self.domain

    def getValue(self):
        """
        get initial conditions Value
        """
        return self.value.getValue()
Exemplo n.º 4
0
class CommonInitialCondition_old:
    """
    Common InitialCondition definition. 
    It means we can use that class for any kind of problem, hydraulic, chemical/transport ...
    """
    def __init__(self, domain=None, value=None):
        """
        domain can be a region of the domain, it could also be a simple body associated to .
        """
        memberShip(domain.support, [CartesianMesh, Body])
        self.domain = domain

        #        if domain !=None:
        #            if isinstance(domain,Region):
        #                memberShip(domain.support,[CartesianMesh, Body])
        #            elif isinstance(domain,Body):
        #                pass
        #            elif isinstance(domain,CartesianMesh):
        #                pass
        #        self.domain = domain
        #
        #
        #
        print("dbg CommonInitialCondition", value)
        if type(value) == None:
            self.value = Head(0.0, "m")
        elif isinstance(value, Head):
            self.value = value
        else:
            raise Exception(" to modify, the pressure must be scaled ")

    def getDomain(self):
        """get initial conditions  zones"""
        return self.domain

    def getRegion(self):
        """get initial conditions  zones"""
        return self.domain

    def getSupport(self):
        """get initial conditions  zones"""
        dir(self.domain)
        return self.domain

    def getValue(self):
        """
        get initial conditions Value
        """
        return self.value.getValue()
Exemplo n.º 5
0
    def __init__(self, body=None, value=None, description=None):
        """
        domain can be a region of the domain, it could also be a simple body associated to.
        """
        if isInstance(body, [CartesianMesh, Body]):
            pass
        else:
            memberShip(body.support, [CartesianMesh, Body])
            pass
        self.body = body
        self.zone = body
        self.domain = body
        #        if domain !=None:
        #            if isinstance(domain,Region):
        #                memberShip(domain.support,[CartesianMesh, Body])
        #            elif isinstance(domain,Body):
        #                pass
        #            elif isinstance(domain,CartesianMesh):
        #                pass
        #        self.domain = domain
        #
        #
        #
        print(" the value for initial condition is: ", type(value), value,
              value.__class__.__name__)
        #raw_input(__name__+": the value for initial condition is")
        if isinstance(value, PhysicalQuantity):
            if not isinstance(value, (Head, Pressure)):
                pass
            else:
                #print "dbg CommonInitialCondition",value
                if type(value) == None:
                    self.value = Head(0.0, "m")
                    pass
                elif isinstance(value, Head):
                    self.value = value
                    pass
                else:
                    self.value = value
                    #raise Exception(" to modify, the pressure must be scaled to be entered as a head")
            if not isinstance(value, (Displacement)):
                pass
            else:
                #print "dbg CommonInitialCondition",value
                if type(value) == None:
                    self.value = Displacement(0.0, "m")
                    pass
                elif isinstance(value, Displacement):
                    self.value = value
                    pass
        elif type(value) in [ListType, TupleType]:
            self.value = {}
            for val in value:
                if isinstance(val,
                              (Head, Pressure, Displacement, Temperature)):
                    print(" value val.__class__.__name__ ",
                          val.__class__.__name__)
                    self.value[val.__class__.__name__] = val
                else:
                    pass
                    #raise Warning("check the way a value of type "+val.__class__.__name__+" can be treated")
                pass

        if description == None:
            print(dir(body))
            self.description = "CommonInitialCondition stretched over the body "
            pass
        else:
            self.description = description
            pass
        return None
Exemplo n.º 6
0
    def setUp(self):
        self.r = redirect.output("modflowcomponent_test.log")
        self.r.toFile()

        #
        # Definition of the mesh
        #
        self.mesh = CartesianMesh2D("global", "XY")
        self.nx = 42
        self.ny = 1
        self.nb_of_intervals = [self.nx, self.ny]
        self.dx = [0.002]
        self.dx = self.dx * self.nx
        self.dx[0] = self.dx[0] * 0.5
        self.pointlist_x = [0.0]
        self.pointlist_y = [0.0]
        for i in range(1, len(self.dx), 1):
            self.pointlist_x.append(self.pointlist_x[i - 1] + self.dx[i - 1])
        self.pointlist_y = [0.0]
        self.pointlist_y.append(1.0)
        self.mesh.setAxis("X", self.pointlist_x)
        self.mesh.setAxis("Y", self.pointlist_y)
        #
        # End of Definitions for the mesh
        #
        #        print " Study name:",self.study._name
        #
        # Definitions of materials
        #
        print "-" * 20
        print " Definition of materials :"
        print "-" * 20
        self.clay_material = Material(name="clay",
                                      permeability=Permeability(1.0, "m/s"))
        self.cement_material = Material(name="Cement",
                                        permeability=Permeability(
                                            2.0e-7, "m/s"))
        #
        print "-" * 20
        print " Definition of meshes :"
        print "-" * 20
        self.clay_reg_m = CartesianMesh2D("Clay Region", "XY")
        self.clay_reg_m.setZone("Clay Region",
                                index_min=Index2D(2, 1),
                                index_max=Index2D(self.nx - 1, 1))
        #
        print "-" * 20
        print " Definition of meshes :"
        print "-" * 20
        self.east_bo_m = CartesianMesh2D("boundary east", "XY")
        self.east_bo_m.setZone("boundary east",
                               index_min=Index2D(1, 1),
                               index_max=Index2D(1, 1))
        #
        # Definition of regions
        #
        print "-" * 25
        print " Definition of regions :"
        print "-" * 25
        self.regions_list = []
        print type(self.clay_reg_m
                   ), " nom de la classe :", self.clay_reg_m.__class__.__name__
        print type(
            self.clay_material
        ), " nom de la classe :", self.clay_material.__class__.__name__
        print "-" * 20
        self.reg1 = Region(self.clay_reg_m, self.clay_material)
        self.regions_list.append(self.reg1)

        #print "  ---- type ----", hasattr(reg1,"material")
        #print "  ---- type ----", hasattr(reg1,"support")
        #temp = reg1.__class__
        #name = temp.__name__
        #print " nom ",name
        #pos = name.find('_objref_')
        #print " pos ",pos
        tclasses = [Region]
        #for c in tclasses:
        #    if isinstance(reg1,c):
        #        print " ok ",c
        #
        # Definition of boundary conditions
        #
        print "-" * 20
        print " Definition of boundary conditions :"
        print "-" * 20
        self.boundaryconditions_list = []
        print "-" * 10
        print " east_bo_m :"
        print "-" * 10

        self.east_bo_m = CartesianMesh2D("boundary east", "XY")
        self.east_min = Index2D(1, 1)
        self.east_max = Index2D(1, 1)
        #east_bo_m.setZone("boundary east",index_min = Index2D(1,1),index_max = Index2D(1,1))
        #east_bo_m.setZone("boundary east",index_min = Index2D(1,1),index_max = Index2D(1,1))
        self.east_bo_m.setZone("boundary east", self.east_min, self.east_max)
        self.Boundary = self.east_bo_m
        self.head_value = Head(2.2e-7, "m")
        print " class name ", self.head_value.__class__.__name__

        self.bc_east = BoundaryCondition(self.Boundary, 'Dirichlet',
                                         self.head_value)
        print " on verifie la classe "
        if not isinstance(self.bc_east, BoundaryCondition):
            raise Exception, " the instanciation of the boundary class must be verified "
        print " on a verifie la classe "
        print " east_bo_m : append"
        self.boundaryconditions_list.append(self.bc_east)
        #
        print "-" * 10
        print " west_bo_w :"
        print "-" * 10

        self.west_bo_m = CartesianMesh2D("boundary west", "XY")
        self.west_bo_m.setZone("boundary west",
                               index_min=Index2D(41, 1),
                               index_max=Index2D(41, 1))
        self.Boundary = self.west_bo_m
        self.Value = Head(0.0, "m")
        self.bc_west = BoundaryCondition(self.Boundary, 'Dirichlet',
                                         self.Value)
        print " east_bo_m : append"
        self.boundaryconditions_list.append(self.bc_west)

        #
        # Definition of initial conditions
        #
        self.initialconditions_list = []
        self.reg1_ic = InitialCondition(self.clay_reg_m,
                                        value=Head(1.e-8, "m"))
        self.initialconditions_list.append(self.reg1_ic)
        # ----------------
        # Darcy Resolution
        # ----------------
        self.title = " One dimensional simulation"
        print "Title of the study : ", self.title
        #
        # Definition of Modflow specific parameters
        #
        self.mxiter = 200
        self.accl = 1.0
        self.hclose = 1.e-15
        print " Study definition "
        self.Study_type = 'Saturated'
        print " SaturatedHydroModflow instance "
        #        self.darcy = SaturatedHydroModflow(self.study._name,self.regions_list,
        #	             self.boundaryconditions_list,self.initialconditions_list)
        self.darcy = SaturatedHydroModflow("Modflow_1/2D", self.regions_list,
                                           self.boundaryconditions_list,
                                           self.initialconditions_list)
        print " SaturatedHydroModflow setMesh method "
        self.darcy.setMesh(self.mesh)
        print " SaturatedHydroModflow setData method "
        self.darcy.setData()
        self.darcy.run()

        self.filename_sip = "Monod.sip"
        self.modflow_sip = setSolverParameter(self.mxiter, self.accl,
                                              self.hclose)
        self.modflow_sip.sauvegarde(self.filename_sip)