source: issm/trunk-jpl/src/m/classes/mismipbasalforcings.py@ 22267

Last change on this file since 22267 was 22267, checked in by kruegern, 7 years ago

ADD: added python versions and dependecies for tests: 243,260,261,293,340,342,343,344,350,430,435,436,437,438,439,441,442,460,461,462,463,464,465,540,701,808,2424,2425

File size: 5.5 KB
Line 
1from fielddisplay import fielddisplay
2from project3d import project3d
3from checkfield import checkfield
4from WriteData import WriteData
5import numpy as np
6
7class mismipbasalforcings(object):
8 """
9 MISMIP Basal Forcings class definition
10
11 Usage:
12 mismipbasalforcings=mismipbasalforcings()
13 """
14
15 def __init__(self): # {{{
16
17 self.groundedice_melting_rate = float('NaN')
18 self.meltrate_factor = float('NaN')
19 self.threshold_thickness = float('NaN')
20 self.upperdepth_melt = float('NaN')
21 self.geothermalflux = float('NaN')
22
23 self.setdefaultparameters()
24
25 #}}}
26 def __repr__(self): # {{{
27 string=" MISMIP+ basal melt parameterization\n"
28 string="%s\n%s"%(string,fielddisplay(self,"groundedice_melting_rate","basal melting rate (positive if melting) [m/yr]"))
29 string="%s\n%s"%(string,fielddisplay(self,"meltrate_factor","Melt-rate rate factor [1/yr] (sign is opposite to MISMIP+ benchmark to remain consistent with ISSM convention of positive values for melting)"))
30 string="%s\n%s"%(string,fielddisplay(self,"threshold_thickness","Threshold thickness for saturation of basal melting [m]"))
31 string="%s\n%s"%(string,fielddisplay(self,"upperdepth_melt","Depth above which melt rate is zero [m]"))
32 string="%s\n%s"%(string,fielddisplay(self,"geothermalflux","Geothermal heat flux [W/m^2]"))
33 return string
34 #}}}
35 def extrude(self,md): # {{{
36 self.groundedice_melting_rate=project3d(md,'vector',self.groundedice_melting_rate,'type','node','layer',1)
37 self.geothermalflux=project3d(md,'vector',self.geothermalflux,'type','node','layer',1) #bedrock only gets geothermal flux
38 return self
39 #}}}
40 def initialize(self,md): # {{{
41 if np.all(np.isnan(self.groundedice_melting_rate)):
42 self.groundedice_melting_rate=np.zeros((md.mesh.numberofvertices))
43 print ' no basalforcings.groundedice_melting_rate specified: values set as zero'
44 if np.all(np.isnan(self.geothermalflux)):
45 self.geothermalflux=np.zeros((md.mesh.numberofvertices))
46 print " no basalforcings.geothermalflux specified: values set as zero"
47 return self
48 #}}}
49 def setdefaultparameters(self): # {{{
50 # default values for melting parameterization
51 self.meltrate_factor = 0.2
52 self.threshold_thickness = 75.
53 self.upperdepth_melt = -100.
54 return self
55 #}}}
56 def checkconsistency(self,md,solution,analyses): # {{{
57
58 #Early return
59 if 'MasstransportAnalysis' in analyses and not (solution=='TransientSolution' and md.transient.ismasstransport==0):
60
61 md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,'Inf',1,'timeseries',1)
62 md = checkfield(md,'fieldname','basalforcings.meltrate_factor','>=',0,'numel',[1])
63 md = checkfield(md,'fieldname','basalforcings.threshold_thickness','>=',0,'numel',[1])
64 md = checkfield(md,'fieldname','basalforcings.upperdepth_melt','<=',0,'numel',[1])
65
66 if 'BalancethicknessAnalysis' in analyses:
67
68 md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
69 md = checkfield(md,'fieldname','basalforcings.meltrate_factor','>=',0,'numel',[1])
70 md = checkfield(md,'fieldname','basalforcings.threshold_thickness','>=',0,'numel',[1])
71 md = checkfield(md,'fieldname','basalforcings.upperdepth_melt','<=',0,'numel',[1])
72
73 if 'ThermalAnalysis' in analyses and not (solution=='TransientSolution' and md.transient.isthermal==0):
74
75 md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,'Inf',1,'timeseries',1)
76 md = checkfield(md,'fieldname','basalforcings.meltrate_factor','>=',0,'numel',[1])
77 md = checkfield(md,'fieldname','basalforcings.threshold_thickness','>=',0,'numel',[1])
78 md = checkfield(md,'fieldname','basalforcings.upperdepth_melt','<=',0,'numel',[1])
79 md = checkfield(md,'fieldname','basalforcings.geothermalflux','NaN',1,'Inf',1,'timeseries',1,'>=',0)
80 return md
81 # }}}
82 def marshall(self,prefix,md,fid): # {{{
83
84 yts=md.constants.yts
85 if yts!=365.2422*24.*3600.:
86 print 'WARNING: value of yts for MISMIP+ runs different from ISSM default!'
87
88 floatingice_melting_rate = np.zeros((md.mesh.numberofvertices))
89 floatingice_melting_rate = md.basalforcings.meltrate_factor*np.tanh((md.geometry.base-md.geometry.bed)/md.basalforcings.threshold_thickness)*(md.basalforcings.upperdepth_melt-md.geometry.base)
90
91 WriteData(fid,prefix,'name','md.basalforcings.model','data',3,'format','Integer')
92 WriteData(fid,prefix,'data',floatingice_melting_rate,'format','DoubleMat','name','md.basalforcings.floatingice_melting_rate','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
93 WriteData(fid,prefix,'object',self,'fieldname','groundedice_melting_rate','format','DoubleMat','name','md.basalforcings.groundedice_melting_rate','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
94 WriteData(fid,prefix,'object',self,'fieldname','geothermalflux','name','md.basalforcings.geothermalflux','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
95 WriteData(fid,prefix,'object',self,'fieldname','meltrate_factor','format','Double','scale',1./yts)
96 WriteData(fid,prefix,'object',self,'fieldname','threshold_thickness','format','Double')
97 WriteData(fid,prefix,'object',self,'fieldname','upperdepth_melt','format','Double')
98
99 # }}}
Note: See TracBrowser for help on using the repository browser.