コード例 #1
0
ファイル: steady_solve.py プロジェクト: lidaan/issm_python
md = im.setflowequation(md, mdl_odr, 'all')
md.flowequation.fe_HO = 'P1'

## set for no-slip basal velocity BC (replaced with high friction above) :
#basal_v                         = md.mesh.vertexonbase
#md.stressbalance.spcvx[basal_v] = 0.0
#md.stressbalance.spcvy[basal_v] = 0.0
#md.stressbalance.spcvz[basal_v] = 0.0

#===============================================================================
# solve :
print_text('::: issm -- solving :::', 'red')

md.cluster = im.generic('name', im.gethostname(), 'np', 1)
md.verbose = im.verbose('convergence', True)
if tmc: md = im.solve(md, 'SteadyState')
else: md = im.solve(md, 'StressBalance')

#===============================================================================
# plot the results :
print_text('::: issm -- plotting :::', 'red')

p = md.results.StressbalanceSolution.Pressure[md.mesh.vertexonbase]
u_x = md.results.StressbalanceSolution.Vx[md.mesh.vertexonsurface]
u_y = md.results.StressbalanceSolution.Vy[md.mesh.vertexonsurface]
u_z = md.results.StressbalanceSolution.Vz[md.mesh.vertexonsurface]
u = np.array([u_x.flatten(), u_y.flatten(), u_z.flatten()])

# save the mesh coordinates and data for interpolation with CSLVR :
np.savetxt(out_dir + 'x.txt', md.mesh.x2d)
np.savetxt(out_dir + 'y.txt', md.mesh.y2d)
コード例 #2
0
md.transient.requested_outputs = [
    'default', 'GroundedArea', 'FloatingArea', 'IceVolume',
    'IceVolumeAboveFloatation'
]

#===============================================================================
print_text('::: issm -- set boundary conditions :::', 'red')

# Set the default boundary conditions for an ice-sheet :
#md = im.SetMarineIceSheetBC(md)  # create placeholder arrays for indicies
md.extrude(6, 1.0)
md = im.setflowequation(md, mdl_odr, 'all')
md.flowequation.fe_HO = 'P1'

#===============================================================================
# save the state of the model :
#im.savevars(out_dir + 'mismip_init.md', 'md', md)

#===============================================================================
# solve :
print_text('::: issm -- solving :::', 'red')

md.cluster = im.generic('name', im.gethostname(), 'np', 4)
md.verbose = im.verbose('solution', True, 'control', True, 'convergence', True)
md = im.solve(md, 'Transient')

#===============================================================================
# save the state of the model :
im.savevars(out_dir + 'mismip_zero_stress.md', 'md', md)
コード例 #3
0
# extrude the mesh so that there are 5 cells in height :
md.extrude(6, 1.0)

# set the flow equation of type `mdl_odr` defined above :
md = im.setflowequation(md, mdl_odr, 'all')
md.flowequation.fe_HO = 'P1'


#===============================================================================
# solve :
print_text('::: issm -- solving initial velocity :::', 'red')

md.cluster = im.generic('name', im.gethostname(), 'np', 1)
md.verbose = im.verbose('convergence', True)
md         = im.solve(md, 'Stressbalance')


#===============================================================================
# FIXME: since the model was extruded, we have to re-define the element-wise 
#        multiplicative identities.  This is not ideal :

# rank-zero tensor vertex ones vector :
v_ones = np.ones(md.mesh.numberofvertices)

# rank-zero tensor element ones vector :
e_ones = np.ones(md.mesh.numberofelements)

# rank-two tensor ones vector :
A_ones = np.ones((md.mesh.numberofvertices, 6))
コード例 #4
0
# n has one value per element :
md.materials.rheology_n = n * np.ones(md.mesh.numberofelements)

#===============================================================================
# solve steady-state solution :
print_text('::: issm -- solving :::', 'red')

#  solver parameters :
md.stressbalance.restol   = 0.01
md.stressbalance.reltol   = 0.1
md.stressbalance.abstol   = np.nan
md.stressbalance.isnewton = 1

md.cluster = im.generic('name', im.gethostname(), 'np', 1)
md.verbose = im.verbose('convergence', True)
md         = im.solve(md, 'Stressbalance')

#===============================================================================
# data assimilation :
md.inversion.iscontrol          = 1 # Do inversion? 1 = yes; 0 = no
md.inversion.incomplete_adjoint = 1 # 1 = linear viscosity; 0 = non-linear visc

# set the control parameter, either 'FrictionCoefficient' 
# or 'MaterialsRheologyBar' :
md.inversion.control_parameters = ['FrictionCoefficient']
md.inversion.nsteps             = 100 # number of inversion steps

# Original value was 0.5 :
md.inversion.step_threshold     = 0.001 * np.ones(md.inversion.nsteps)

# original value was 5 :