tsia.py - pism - [fork] customized build of PISM, the parallel ice sheet model (tillflux branch)
 (HTM) git clone git://src.adamsgaard.dk/pism
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) LICENSE
       ---
       tsia.py (2452B)
       ---
            1 # Copyright (C) 2011, 2012, 2014, 2015, 2016, 2017, 2018 David Maxwell and Constantine Khroulev
            2 #
            3 # This file is part of PISM.
            4 #
            5 # PISM is free software; you can redistribute it and/or modify it under the
            6 # terms of the GNU General Public License as published by the Free Software
            7 # Foundation; either version 3 of the License, or (at your option) any later
            8 # version.
            9 #
           10 # PISM is distributed in the hope that it will be useful, but WITHOUT ANY
           11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
           12 # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
           13 # details.
           14 #
           15 # You should have received a copy of the GNU General Public License
           16 # along with PISM; if not, write to the Free Software
           17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
           18 
           19 """Module containing helper functions for using the SIA stress balance
           20 model."""
           21 
           22 import PISM
           23 
           24 def computeSIASurfaceVelocities(modeldata, siasolver=PISM.SIAFD):
           25     """Generates surface horizontal velocities corresponding to solving
           26     the SIA with zero basal sliding.
           27 
           28     :param `modeldata`: :class:`PISM.model.ModelData` containing
           29                         variables and model physics
           30 
           31     :param `siasolver`: specific class used for solving the SIA
           32 
           33     """
           34     md = modeldata
           35     grid = md.grid
           36     sia = siasolver(grid)
           37     sia.init()
           38 
           39     geometry = PISM.Geometry(grid)
           40 
           41     geometry.ice_thickness.copy_from(md.vecs.thk)
           42     geometry.bed_elevation.copy_from(md.vecs.topg)
           43     geometry.sea_level_elevation.set(0.0)
           44     geometry.ice_area_specific_volume.set(0.0)
           45 
           46     geometry.ensure_consistency(md.config.get_number("geometry.ice_free_thickness_standard"))
           47 
           48     inputs = PISM.StressBalanceInputs()
           49 
           50     inputs.geometry = geometry
           51     inputs.basal_melt_rate = None
           52     inputs.melange_back_pressure = None
           53     inputs.basal_yield_stress = None
           54     inputs.enthalpy = md.vecs.enthalpy
           55     inputs.age = None
           56 
           57     sliding_velocity = PISM.IceModelVec2V()
           58     sliding_velocity.create(grid, 'sliding_velocity', False)
           59     sliding_velocity.set(0.0)
           60 
           61     sia.update(sliding_velocity, inputs, True)
           62     u = sia.velocity_u()
           63     v = sia.velocity_v()
           64 
           65     vel_sia = PISM.model.create2dVelocityVec(grid, name="_sia", stencil_width=1)
           66     tmp = PISM.IceModelVec2S(grid, 'tmp', False)
           67 
           68     u.getSurfaceValues(tmp, md.vecs.thk)
           69     vel_sia.set_component(0, tmp)
           70 
           71     v.getSurfaceValues(tmp, md.vecs.thk)
           72     vel_sia.set_component(1, tmp)
           73 
           74     return vel_sia