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

Last change on this file since 20690 was 20690, checked in by Mathieu Morlighem, 9 years ago

NEW: marhsall strings instead of enums

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