本文整理汇总了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