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)
# brent search specific parameters : elif opt_met == 'brent': md.inversion.step_threshold = 0.7 * np.ones(md.inversion.nsteps) md.inversion.maxiter_per_step = 20 * np.ones(md.inversion.nsteps) md.inversion.gradient_scaling = 50 * np.ones(md.inversion.nsteps) md.inversion.cost_function_threshold = np.nan ## FIXME: it is not obvious that the velocity observations have to be extruded : #md.inversion.vx_obs = im.project3d(md,'vector', # md.inversion.vx_obs,'type','node') #md.inversion.vy_obs = im.project3d(md,'vector', # md.inversion.vy_obs,'type','node') #md.inversion.vel_obs = im.project3d(md,'vector', # md.inversion.vel_obs,'type','node') #print md.inversion.vx_obs #print md.inversion.vy_obs #print md.inversion.vel_obs #=============================================================================== # assimilate the velocity data : md.cluster = im.generic('name', im.gethostname(), 'np', 2) md.verbose = im.verbose('solution', True, 'control', True) md = im.solve(md, 'Stressbalance') im.savevars(out_dir + name + '.md', 'md', md)
# specifiy the flow equation and FE basis : md = im.setflowequation(md, mdl_odr, 'all') md.flowequation.fe_HO = 'P1' ## set no-slip basal velocity BC : ## FIXME: if you do not call ``md.extrude()`` before, ``md.mesh.vertexonbase`` ## does not exist. #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 #=============================================================================== # save the state of the model : im.savevars(out_dir + 'mismip_init.md', 'md', md) #=============================================================================== # solve : ## initialize the velocity for the CFL condition: #md.cluster = im.generic('name', im.gethostname(), 'np', 2) #md.verbose = im.verbose('solution', True, 'convergence', True) #md = im.solve(md, 'Stressbalance') # #md.initialization.vx = md.results.StressbalanceSolution.Vx #md.initialization.vy = md.results.StressbalanceSolution.Vy #md.initialization.vz = md.results.StressbalanceSolution.Vz #md.initialization.vel = md.results.StressbalanceSolution.Vel # solve the transient :
mask[mask == 2] = -1 # ice is grounded for mask equal one md.mask.groundedice_levelset = mask # ice is present when negative : md.mask.ice_levelset = -1 * np.ones(md.mesh.numberofvertices) #=============================================================================== # geometry : cs.print_text('::: issm -- constructing geometry :::', 'red') S = im.InterpFromGridToMesh(dbm.x, dbm.y, dbm.data['S'], md.mesh.x, md.mesh.y, 0)[0] B = im.InterpFromGridToMesh(dbm.x, dbm.y, dbm.data['B'], md.mesh.x, md.mesh.y, 0)[0] S = S.astype('float64') B = B.astype('float64') # upper surface : md.geometry.surface = S # lower surface : md.geometry.base = B #thickness is the difference between surface and base : md.geometry.thickness = md.geometry.surface - md.geometry.base # save the state of the model : im.savevars(var_dir + 'issm_vars.md', 'md', md)
# change data type to that required by InterpFromGridToMesh() : x1 = dmg.x.astype('float64') y1 = dmg.y.astype('float64') velx = dmg.data['vx'].astype('float64') vely = dmg.data['vy'].astype('float64') # calculate the velocity magnitude : vel = np.sqrt(velx**2 + vely**2) # interpolate the data onto the issm mesh : vx = im.InterpFromGridToMesh(x1, y1, velx, md.mesh.x, md.mesh.y, 0)[0] vy = im.InterpFromGridToMesh(x1, y1, vely, md.mesh.x, md.mesh.y, 0)[0] u_mag = im.InterpFromGridToMesh(x1, y1, vel, md.mesh.x, md.mesh.y, 0)[0] # while we have the velocity observations, save them to the model now for # inversion later : md.inversion.vx_obs = velx md.inversion.vy_obs = vely md.inversion.vel_obs = vel # refine mesh using surface velocities as metric : md = im.bamg(md, 'hmin', 5000, 'hmax', 500000, 'gradation', 3, 'field', u_mag, 'err', 8) # plot the mesh to be sure : #im.plotmodel(md, 'data', 'mesh') #=============================================================================== # save the state of the model : im.savevars(out_dir + 'issm_refined_mesh.md', 'md', md)
#=============================================================================== # save the state of the model : var_dict = { 'md.mask.groundedice_levelset': md.mask.groundedice_levelset, 'md.mask.ice_levelset': md.mask.ice_levelset, 'md.initialization.temperature': md.initialization.temperature, 'md.geometry.surface': md.geometry.surface, 'md.geometry.base': md.geometry.base, 'md.geometry.thickness': md.geometry.thickness, 'md.inversion.vx_obs': md.inversion.vx_obs, 'md.inversion.vy_obs': md.inversion.vy_obs, 'md.inversion.vel_obs': md.inversion.vel_obs, 'md.friction_coefficient': md.friction.coefficient } im.savevars(out_dir + 'issm_nio.shelve', var_dict) #=============================================================================== # plot the data : tp_kwargs = {'linestyle': '-', 'lw': 0.1, 'color': 'k', 'alpha': 0.5} quiver_kwargs = { 'pivot': 'middle', 'color': '0.0', 'scale': 100, 'alpha': 1.0, 'width': 0.001, 'headwidth': 3.0, 'headlength': 3.0, 'headaxislength': 3.0 }
# calculate the velocity magnitude : vel = np.sqrt(velx**2 + vely**2) # interpolate the data onto the issm mesh : u_mag = im.InterpFromGridToMesh(x1, y1, vel, md.mesh.x, md.mesh.y, 0)[0] # refine mesh using surface velocities as metric : md = im.bamg(md, 'hmax', 100000, 'hmin', 1000, 'gradation', 100, 'field', u_mag, 'err', 8) # FIXME: doesn't work : # plot the mesh to be sure : #im.plotmodel(md, 'data', 'mesh') #=============================================================================== # save the state of the model : # FIXME: the savevars method will work for small problems, but fails without # error for large ones. Thus this doesn't work : # # im.savevars(out_dir + 'issm_refined_mesh.md', 'md', md) # # and instead we do this : im.savevars(out_dir + 'issm_nio.shelve', 'md.mesh', md.mesh)