コード例 #1
0
ファイル: model_advection.py プロジェクト: pvthinker/Nyles
 def __init__(self, param, grid):
     self.state = var.get_state(param)
     self.traclist = ['b']
     self.order = param['orderA']
     self.diff_coef = param['diff_coef']
     self.halo = halo.set_halo(param, self.state)
     self.timescheme = ts.Timescheme(param, self.state)
     self.timescheme.set(self.rhs, self.diagnose_var)
     self.param = param
     self.grid = grid
     self.tracer = tracer.Tracer_numerics(
         grid, self.traclist, self.order, self.diff_coef)
     self.stats = []
コード例 #2
0
 def __init__(self, param):
     # Create a State object for the LES model
     self.state = get_state(param)
     # Make U and all its components prognostic.  This should
     # actually be done before the state is created, but I don't want
     # to mess with variables.py at the moment.  This must be done
     # before the timescheme is created.
     self.state.U.prognostic = True
     for i in "ijk":
         self.state.U[i].prognostic = True
     # Create and set-up a handler for the timescheme
     self.timescheme = Timescheme(param, self.state)
     self.timescheme.set(compute_rhs)
コード例 #3
0
    def __init__(self, param, grid, linear=False):
        self.nonlinear = not linear
        self.grid = grid
        self.traclist = ['b']
        # Add tracers (if any)
        for i in range(param["n_tracers"]):
            t_nickname = "t{}".format(i)
            t_name = "tracer{}".format(i)
            self.traclist.append(t_nickname)
            var.modelvar[t_nickname] = var.ModelVariable('scalar',
                                                         t_name,
                                                         dimension='',
                                                         prognostic=True)
        self.state = var.get_state(param)
        self.halo = halo.set_halo(param, self.state)
        self.neighbours = param["neighbours"]
        self.timescheme = ts.Timescheme(param, self.state)
        self.timescheme.set(self.rhs, self.diagnose_var)
        self.orderA = param["orderA"]
        self.orderVF = param["orderVF"]
        self.orderKE = param["orderKE"]
        self.rotating = param["rotating"]
        self.forced = param["forced"]
        self.diff_coef = param['diff_coef']
        self.add_viscosity = "u" in self.diff_coef.keys()
        if self.add_viscosity:
            self.viscosity = self.diff_coef['u']

        self.tracer = tracer.Tracer_numerics(param, grid, self.traclist,
                                             self.orderA, self.diff_coef)
        if self.rotating:
            # convert Coriolis parameter (in s^-1) into its covariant quantity
            # i.e. multiply with cell horizontal area
            area = self.grid.dx * self.grid.dy
            self.fparameter = param["coriolis"] * area
        else:
            self.fparameter = 0.
        self.mg = mg.Multigrid(param, grid)
        self.stats = []
コード例 #4
0
        'Lz': 1.0,
        'timestepping': 'LFAM3',
        'neighbours': neighbours,
        'procs': procs,
        'myrank': myrank,
        'npre': 3,
        'npost': 3,
        'omega': 0.8,
        'ndeepest': 20,
        'maxite': 20,
        'tol': 1e-12
    }

    grid = grid_module.Grid(param)

    s = var.get_state(param)
    ds = s.duplicate_prognostic_variables()
    mg = mg.Multigrid(param)
    u = ds.u['i'].view('i')
    v = ds.u['j'].view('i')
    w = ds.u['k'].view('i')

    print('set up a localized jet along the i-direction')
    k1 = nz // 3
    k2 = 2 * nz // 3
    j1 = ny // 3
    j2 = 2 * ny // 3
    u[k1:k2, j1:j2, :-1] = 1.
    v[:, :-1, :] = 0
    w[:-1, :, :] = 0
コード例 #5
0
ファイル: nylesIO.py プロジェクト: cpierard/Nyles
        # Parameters necessary for State and/or Grid
        "Lx": 60,
        "Ly": 50,
        "Lz": 10,
        "nx": 6,
        "ny": 5,
        "nz": 4,
        "nh": 3,
        "neighbours":
        {},  # TODO: try with neighbours when halo-handling is implemented
        # Parameters to test the storage of parameters in the history file
        "a boolean variable": True,
        "a 2nd boolean variable": False,
        "a long list": list(range(50)),
    }
    state = get_state(param)
    print("* Full state:")
    print(state)

    grid = Grid(param)

    io = NylesIO(param)
    print("* Output directory:", io.output_directory)
    print("* History file:", io.hist_path)
    print("* Experiment parameters to save:")
    print(io.experiment_parameters)
    io.init(state, grid)
    print("* Variables in the history file:")
    print(io.hist_variables)
    b = state.get("b").view("i")
    for i, t in enumerate([0.2, 0.5, 0.7, 1.0, 1.5, 2.1, 3.0]):