当前位置: 首页>>代码示例>>Python>>正文


Python PISM.max_timestep_cfl_2d方法代码示例

本文整理汇总了Python中PISM.max_timestep_cfl_2d方法的典型用法代码示例。如果您正苦于以下问题:Python PISM.max_timestep_cfl_2d方法的具体用法?Python PISM.max_timestep_cfl_2d怎么用?Python PISM.max_timestep_cfl_2d使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PISM的用法示例。


在下文中一共展示了PISM.max_timestep_cfl_2d方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

# 需要导入模块: import PISM [as 别名]
# 或者: from PISM import max_timestep_cfl_2d [as 别名]
def run(Mx, My, t_final, part_grid, C=1.0):
    "Test GeometryEvolution::step()"

    ctx = PISM.Context().ctx

    config = PISM.Context().config

    config.set_boolean("geometry.part_grid.enabled", part_grid)

    grid = PISM.IceGrid_Shallow(ctx, 1, 1, 0, 0, Mx, My, PISM.CELL_CORNER, PISM.NOT_PERIODIC)

    assert t_final <= 1.0

    L = min(grid.Lx(), grid.Ly())
    R_inner = 0.25 * L
    spreading_velocity = 0.7
    R_outer = R_inner + spreading_velocity * t_final

    geometry = PISM.Geometry(grid)

    v         = PISM.IceModelVec2V(grid, "velocity", PISM.WITHOUT_GHOSTS)
    Q         = PISM.IceModelVec2Stag(grid, "Q", PISM.WITHOUT_GHOSTS)
    v_bc_mask = PISM.IceModelVec2Int(grid, "v_bc_mask", PISM.WITHOUT_GHOSTS)
    H_bc_mask = PISM.IceModelVec2Int(grid, "H_bc_mask", PISM.WITHOUT_GHOSTS)

    ge = PISM.GeometryEvolution(grid)

    # grid info
    geometry.latitude.set(0.0)
    geometry.longitude.set(0.0)
    # environment
    geometry.bed_elevation.set(-10.0)
    geometry.sea_level_elevation.set(0.0)
    # set initial ice thickness
    disc(geometry.ice_thickness, 0, 0, 1, R_inner, R_inner)
    geometry.ice_area_specific_volume.set(0.0)

    geometry.ensure_consistency(0.0)

    set_velocity(spreading_velocity, v)
    v_bc_mask.set(0.0)
    disc(H_bc_mask, 0, 0, 1, R_inner, R_inner)

    profiling = ctx.profiling()
    profiling.start()

    t = 0.0
    j = 0
    profiling.stage_begin("ge")
    while t < t_final:
        dt = PISM.max_timestep_cfl_2d(geometry.ice_thickness,
                                      geometry.cell_type,
                                      v).dt_max.value() * C

        if t + dt > t_final:
            dt = t_final - t

        log.message(2, "{}, {}\n".format(t, dt))

        profiling.begin("step")
        ge.flow_step(geometry, dt,
                     v,
                     Q,
                     v_bc_mask,
                     H_bc_mask)
        profiling.end("step")

        profiling.begin("modify")
        ge.apply_flux_divergence(geometry)
        geometry.ensure_consistency(0.0)
        profiling.end("modify")

        t += dt
        j += 1
    profiling.stage_end("ge")

    profiling.report("profiling_%d_%d.py" % (Mx, My))

    return geometry
开发者ID:pism,项目名称:pism,代码行数:81,代码来源:mass_transport.py


注:本文中的PISM.max_timestep_cfl_2d方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。