예제 #1
0
파일: simulation.py 프로젝트: scanks/pyro2
    def initialize(self):
        """
        Initialize the grid and variables for compressible flow and set
        the initial conditions for the chosen problem.
        """
        
        my_grid = grid_setup(self.rp, ng=4)
        my_data = patch.CellCenterData2d(my_grid)


        # define solver specific boundary condition routines
        patch.define_bc("hse", BC.user, is_solid=False)

        bc, bc_xodd, bc_yodd = bc_setup(self.rp)

        # are we dealing with solid boundaries? we'll use these for
        # the Riemann solver
        self.solid = BCProp(int(patch.bc_props[self.rp.get_param("mesh.xlboundary")]),
                            int(patch.bc_props[self.rp.get_param("mesh.xrboundary")]),
                            int(patch.bc_props[self.rp.get_param("mesh.ylboundary")]),
                            int(patch.bc_props[self.rp.get_param("mesh.yrboundary")]))

        # density and energy
        my_data.register_var("density", bc)
        my_data.register_var("energy", bc)
        my_data.register_var("x-momentum", bc_xodd)
        my_data.register_var("y-momentum", bc_yodd)


        # store the EOS gamma as an auxillary quantity so we can have a
        # self-contained object stored in output files to make plots.
        # store grav because we'll need that in some BCs
        my_data.set_aux("gamma", self.rp.get_param("eos.gamma"))
        my_data.set_aux("grav", self.rp.get_param("compressible.grav"))

        my_data.create()

        self.cc_data = my_data

        # some auxillary data that we'll need to fill GC in, but isn't
        # really part of the main solution
        aux_data = patch.CellCenterData2d(my_grid)
        aux_data.register_var("ymom_src", bc_yodd)
        aux_data.register_var("E_src", bc)
        aux_data.create()
        self.aux_data = aux_data

        self.vars = Variables(idens = my_data.vars.index("density"),
                              ixmom = my_data.vars.index("x-momentum"),
                              iymom = my_data.vars.index("y-momentum"),
                              iener = my_data.vars.index("energy"))


        # initial conditions for the problem
        exec(self.problem_name + '.init_data(self.cc_data, self.rp)')

        if self.verbose > 0: print(my_data)
예제 #2
0
파일: simulation.py 프로젝트: jgarani/pyro2
    def initialize(self):
        """
        Initialize the grid and variables for compressible flow and set
        the initial conditions for the chosen problem.
        """
        
        my_grid = grid_setup(self.rp, ng=4)
        my_data = patch.CellCenterData2d(my_grid)


        # define solver specific boundary condition routines
        patch.define_bc("hse", BC.user)

        bc, bc_xodd, bc_yodd = bc_setup(self.rp)

        # density and energy
        my_data.register_var("density", bc)
        my_data.register_var("energy", bc)
        my_data.register_var("x-momentum", bc_xodd)
        my_data.register_var("y-momentum", bc_yodd)


        # store the EOS gamma as an auxillary quantity so we can have a
        # self-contained object stored in output files to make plots.
        # store grav because we'll need that in some BCs
        my_data.set_aux("gamma", self.rp.get_param("eos.gamma"))
        my_data.set_aux("grav", self.rp.get_param("compressible.grav"))

        my_data.create()

        self.cc_data = my_data

        self.vars = Variables(idens = my_data.vars.index("density"),
                              ixmom = my_data.vars.index("x-momentum"),
                              iymom = my_data.vars.index("y-momentum"),
                              iener = my_data.vars.index("energy"))


        # initial conditions for the problem
        exec(self.problem_name + '.init_data(self.cc_data, self.rp)')

        if self.verbose > 0: print(my_data)
예제 #3
0
    def initialize(self):
        """
        Initialize the grid and variables for compressible flow and set
        the initial conditions for the chosen problem.
        """

        my_grid = grid_setup(self.rp, ng=4)
        my_data = patch.CellCenterData2d(my_grid)

        # define solver specific boundary condition routines
        patch.define_bc("hse", BC.user)

        bc, bc_xodd, bc_yodd = bc_setup(self.rp)

        # density and energy
        my_data.register_var("density", bc)
        my_data.register_var("energy", bc)
        my_data.register_var("x-momentum", bc_xodd)
        my_data.register_var("y-momentum", bc_yodd)

        # store the EOS gamma as an auxillary quantity so we can have a
        # self-contained object stored in output files to make plots.
        # store grav because we'll need that in some BCs
        my_data.set_aux("gamma", self.rp.get_param("eos.gamma"))
        my_data.set_aux("grav", self.rp.get_param("compressible.grav"))

        my_data.create()

        self.cc_data = my_data

        self.vars = Variables(idens=my_data.vars.index("density"),
                              ixmom=my_data.vars.index("x-momentum"),
                              iymom=my_data.vars.index("y-momentum"),
                              iener=my_data.vars.index("energy"))

        # initial conditions for the problem
        exec(self.problem_name + '.init_data(self.cc_data, self.rp)')

        if self.verbose > 0: print(my_data)
예제 #4
0
    def initialize(self):
        """
        Initialize the grid and variables for compressible flow and set
        the initial conditions for the chosen problem.
        """

        # setup the grid
        nx = self.rp.get_param("mesh.nx")
        ny = self.rp.get_param("mesh.ny")

        xmin = self.rp.get_param("mesh.xmin")
        xmax = self.rp.get_param("mesh.xmax")
        ymin = self.rp.get_param("mesh.ymin")
        ymax = self.rp.get_param("mesh.ymax")

        verbose = self.rp.get_param("driver.verbose")

        my_grid = patch.Grid2d(nx,
                               ny,
                               xmin=xmin,
                               xmax=xmax,
                               ymin=ymin,
                               ymax=ymax,
                               ng=4)

        # create the variables
        my_data = patch.CellCenterData2d(my_grid)

        # define solver specific boundary condition routines
        patch.define_bc("hse", BC.user)

        # first figure out the boundary conditions.  Note: the action
        # can depend on the variable (for reflecting BCs)
        xlb_type = self.rp.get_param("mesh.xlboundary")
        xrb_type = self.rp.get_param("mesh.xrboundary")
        ylb_type = self.rp.get_param("mesh.ylboundary")
        yrb_type = self.rp.get_param("mesh.yrboundary")

        bc = patch.BCObject(xlb=xlb_type,
                            xrb=xrb_type,
                            ylb=ylb_type,
                            yrb=yrb_type)

        # density and energy
        my_data.register_var("density", bc)
        my_data.register_var("energy", bc)
        my_data.register_var("erad", bc)

        # for velocity, if we are reflecting, we need odd reflection
        # in the normal direction.

        # x-momentum -- if we are reflecting in x, then we need to
        # reflect odd
        bc_xodd = patch.BCObject(xlb=xlb_type,
                                 xrb=xrb_type,
                                 ylb=ylb_type,
                                 yrb=yrb_type,
                                 odd_reflect_dir="x")

        my_data.register_var("x-momentum", bc_xodd)

        # y-momentum -- if we are reflecting in y, then we need to
        # reflect odd
        bc_yodd = patch.BCObject(xlb=xlb_type,
                                 xrb=xrb_type,
                                 ylb=ylb_type,
                                 yrb=yrb_type,
                                 odd_reflect_dir="y")

        my_data.register_var("y-momentum", bc_yodd)

        # store grav because we'll need that in some BCs
        my_data.set_aux("grav", self.rp.get_param("compressible.grav"))

        my_data.create()

        self.cc_data = my_data

        self.vars = Variables(idens=my_data.vars.index("density"),
                              ixmom=my_data.vars.index("x-momentum"),
                              iymom=my_data.vars.index("y-momentum"),
                              iener=my_data.vars.index("energy"),
                              ierad=my_data.vars.index("erad"))

        # initial conditions for the problem
        exec(self.problem_name + '.init_data(self.cc_data, self.rp)')

        if verbose > 0: print(my_data)
예제 #5
0
파일: initialize.py 프로젝트: jzuhone/pyro2
def initialize(rp):
    """ 
    initialize the grid and variables for compressible flow
    """
    import vars

    # setup the grid
    nx = rp.get_param("mesh.nx")
    ny = rp.get_param("mesh.ny")

    xmin = rp.get_param("mesh.xmin")
    xmax = rp.get_param("mesh.xmax")
    ymin = rp.get_param("mesh.ymin")
    ymax = rp.get_param("mesh.ymax")
    
    my_grid = patch.Grid2d(nx, ny, 
                           xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, 
                           ng=4)


    # create the variables
    my_data = patch.CellCenterData2d(my_grid, runtime_parameters=rp)


    # define solver specific boundary condition routines
    patch.define_bc("hse", BC.user)


    # first figure out the boundary conditions.  Note: the action
    # can depend on the variable (for reflecting BCs)
    xlb_type = rp.get_param("mesh.xlboundary")
    xrb_type = rp.get_param("mesh.xrboundary")
    ylb_type = rp.get_param("mesh.ylboundary")
    yrb_type = rp.get_param("mesh.yrboundary")    
    
    bc = patch.BCObject(xlb=xlb_type, xrb=xrb_type,
                        ylb=ylb_type, yrb=yrb_type)

    # density and energy
    my_data.register_var("density", bc)
    my_data.register_var("energy", bc)

    # for velocity, if we are reflecting, we need odd reflection
    # in the normal direction.

    # x-momentum -- if we are reflecting in x, then we need to
    # reflect odd
    bc_xodd = patch.BCObject(xlb=xlb_type, xrb=xrb_type,
                             ylb=ylb_type, yrb=yrb_type,
                             odd_reflect_dir="x")

    my_data.register_var("x-momentum", bc_xodd)    


    # y-momentum -- if we are reflecting in y, then we need to
    # reflect odd
    bc_yodd = patch.BCObject(xlb=xlb_type, xrb=xrb_type,
                             ylb=ylb_type, yrb=yrb_type,
                             odd_reflect_dir="y")

    my_data.register_var("y-momentum", bc_yodd)    


    # store the EOS gamma as an auxillary quantity so we can have a
    # self-contained object stored in output files to make plots
    gamma = rp.get_param("eos.gamma")
    my_data.set_aux("gamma", gamma)

    # initialize the EOS gamma
    eos.init(gamma)
        
    my_data.create()


    vars.idens = my_data.vars.index("density")
    vars.ixmom = my_data.vars.index("x-momentum")
    vars.iymom = my_data.vars.index("y-momentum")
    vars.iener = my_data.vars.index("energy")

    print my_data

    return my_grid, my_data
예제 #6
0
def initialize(rp):
    """ 
    initialize the grid and variables for compressible flow
    """
    import vars

    # setup the grid
    nx = rp.get_param("mesh.nx")
    ny = rp.get_param("mesh.ny")

    xmin = rp.get_param("mesh.xmin")
    xmax = rp.get_param("mesh.xmax")
    ymin = rp.get_param("mesh.ymin")
    ymax = rp.get_param("mesh.ymax")

    my_grid = patch.Grid2d(nx,
                           ny,
                           xmin=xmin,
                           xmax=xmax,
                           ymin=ymin,
                           ymax=ymax,
                           ng=4)

    # create the variables
    my_data = patch.CellCenterData2d(my_grid, runtime_parameters=rp)

    # define solver specific boundary condition routines
    patch.define_bc("hse", BC.user)

    # first figure out the boundary conditions.  Note: the action
    # can depend on the variable (for reflecting BCs)
    xlb_type = rp.get_param("mesh.xlboundary")
    xrb_type = rp.get_param("mesh.xrboundary")
    ylb_type = rp.get_param("mesh.ylboundary")
    yrb_type = rp.get_param("mesh.yrboundary")

    bc = patch.BCObject(xlb=xlb_type, xrb=xrb_type, ylb=ylb_type, yrb=yrb_type)

    # density and energy
    my_data.register_var("density", bc)
    my_data.register_var("energy", bc)

    # for velocity, if we are reflecting, we need odd reflection
    # in the normal direction.

    # x-momentum -- if we are reflecting in x, then we need to
    # reflect odd
    bc_xodd = patch.BCObject(xlb=xlb_type,
                             xrb=xrb_type,
                             ylb=ylb_type,
                             yrb=yrb_type,
                             odd_reflect_dir="x")

    my_data.register_var("x-momentum", bc_xodd)

    # y-momentum -- if we are reflecting in y, then we need to
    # reflect odd
    bc_yodd = patch.BCObject(xlb=xlb_type,
                             xrb=xrb_type,
                             ylb=ylb_type,
                             yrb=yrb_type,
                             odd_reflect_dir="y")

    my_data.register_var("y-momentum", bc_yodd)

    # store the EOS gamma as an auxillary quantity so we can have a
    # self-contained object stored in output files to make plots
    gamma = rp.get_param("eos.gamma")
    my_data.set_aux("gamma", gamma)

    # initialize the EOS gamma
    eos.init(gamma)

    my_data.create()

    vars.idens = my_data.vars.index("density")
    vars.ixmom = my_data.vars.index("x-momentum")
    vars.iymom = my_data.vars.index("y-momentum")
    vars.iener = my_data.vars.index("energy")

    print my_data

    return my_grid, my_data
예제 #7
0
    def initialize(self):
        """
        Initialize the grid and variables for compressible flow and set
        the initial conditions for the chosen problem.
        """

        # setup the grid
        nx = self.rp.get_param("mesh.nx")
        ny = self.rp.get_param("mesh.ny")

        xmin = self.rp.get_param("mesh.xmin")
        xmax = self.rp.get_param("mesh.xmax")
        ymin = self.rp.get_param("mesh.ymin")
        ymax = self.rp.get_param("mesh.ymax")

        verbose = self.rp.get_param("driver.verbose")
        
        my_grid = patch.Grid2d(nx, ny,
                               xmin=xmin, xmax=xmax,
                               ymin=ymin, ymax=ymax, ng=4)


        # create the variables
        my_data = patch.CellCenterData2d(my_grid)


        # define solver specific boundary condition routines
        patch.define_bc("hse", BC.user)


        # first figure out the boundary conditions.  Note: the action
        # can depend on the variable (for reflecting BCs)
        xlb_type = self.rp.get_param("mesh.xlboundary")
        xrb_type = self.rp.get_param("mesh.xrboundary")
        ylb_type = self.rp.get_param("mesh.ylboundary")
        yrb_type = self.rp.get_param("mesh.yrboundary")

        bc = patch.BCObject(xlb=xlb_type, xrb=xrb_type,
                            ylb=ylb_type, yrb=yrb_type)

        # density and energy
        my_data.register_var("density", bc)
        my_data.register_var("energy", bc)
        my_data.register_var("erad", bc)        

        # for velocity, if we are reflecting, we need odd reflection
        # in the normal direction.

        # x-momentum -- if we are reflecting in x, then we need to
        # reflect odd
        bc_xodd = patch.BCObject(xlb=xlb_type, xrb=xrb_type,
                                 ylb=ylb_type, yrb=yrb_type,
                                 odd_reflect_dir="x")

        my_data.register_var("x-momentum", bc_xodd)


        # y-momentum -- if we are reflecting in y, then we need to
        # reflect odd
        bc_yodd = patch.BCObject(xlb=xlb_type, xrb=xrb_type,
                                 ylb=ylb_type, yrb=yrb_type,
                                 odd_reflect_dir="y")

        my_data.register_var("y-momentum", bc_yodd)


        # store grav because we'll need that in some BCs
        my_data.set_aux("grav", self.rp.get_param("compressible.grav"))

        my_data.create()

        self.cc_data = my_data

        self.vars = Variables(idens = my_data.vars.index("density"),
                              ixmom = my_data.vars.index("x-momentum"),
                              iymom = my_data.vars.index("y-momentum"),
                              iener = my_data.vars.index("energy"),
                              ierad = my_data.vars.index("erad"))        


        # initial conditions for the problem
        exec(self.problem_name + '.init_data(self.cc_data, self.rp)')

        if verbose > 0: print(my_data)