Changeset 25688
- Timestamp:
- 10/19/20 13:31:26 (4 years ago)
- Location:
- issm/trunk-jpl
- Files:
-
- 3 added
- 86 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src
-
issm/trunk-jpl/src/c
- Property svn:ignore
-
old new 23 23 issm_ocean 24 24 issm_dakota 25 issm_post
-
- Property svn:ignore
-
issm/trunk-jpl/src/c/classes/Dakota
- Property svn:ignore
-
old new 1 1 .deps 2 .dirstamp
-
- Property svn:ignore
-
issm/trunk-jpl/src/c/classes/Inputs
-
Property svn:ignore
set to
.deps
.dirstamp
-
Property svn:ignore
set to
-
issm/trunk-jpl/src/c/modules/FrontalForcingsx
-
Property svn:ignore
set to
.deps
.dirstamp
-
Property svn:ignore
set to
-
issm/trunk-jpl/src/c/modules/KillIcebergsx
-
Property svn:ignore
set to
.dirstamp
.deps
-
Property svn:ignore
set to
-
issm/trunk-jpl/src/c/modules/OceanExchangeDatax
-
Property svn:ignore
set to
.deps
-
Property svn:ignore
set to
-
issm/trunk-jpl/src/c/modules/QmuStatisticsx
-
Property svn:ignore
set to
.deps
.dirstamp
-
Property svn:ignore
set to
-
issm/trunk-jpl/src/c/modules/QmuStatisticsx/QmuStatisticsx.cpp
r25639 r25688 1001 1001 } 1002 1002 1003 _printf0_("Done with MeanVariance 1003 _printf0_("Done with MeanVariance:\n"); 1004 1004 IssmComm::SetComm(ISSM_MPI_COMM_WORLD); 1005 1005 … … 1161 1161 } 1162 1162 } 1163 _printf0_("Done with SampleSeries 1163 _printf0_("Done with SampleSeries:\n"); 1164 1164 IssmComm::SetComm(ISSM_MPI_COMM_WORLD); 1165 1165 -
issm/trunk-jpl/src/c/toolkits/codipack
-
Property svn:ignore
set to
.deps
-
Property svn:ignore
set to
-
issm/trunk-jpl/src/m/classes/SMBcomponents.py
r24793 r25688 1 import numpy as np 2 3 from checkfield import * 1 4 from fielddisplay import fielddisplay 2 from checkfield import *3 5 from project3d import * 4 6 from WriteData import * … … 6 8 7 9 class SMBcomponents(object): 8 """ 9 SMBcomponents Class definition 10 """SMBCOMPONENTS class definition 10 11 11 12 12 Usage: 13 SMBcomponents = SMBcomponents() 13 14 """ 14 15 15 def __init__(self): # {{{ 16 self.accumulation = float('NaN') 17 self.runoff = float('NaN') 18 self.evaporation = float('NaN') 16 def __init__(self, *args): # {{{ 19 17 self.isclimatology = 0 18 self.accumulation = np.nan 19 self.runoff = np.nan 20 self.evaporation = np.nan 20 21 self.steps_per_step = 1 21 22 self.averaging = 0 22 23 self.requested_outputs = [] 24 25 nargs = len(args) 26 if nargs == 0: 27 pass 28 else: 29 raise Exception('constructor not supported') 23 30 # }}} 24 31 25 32 def __repr__(self): # {{{ 26 s tring = " surface forcings parameters (SMB = accumulation-runoff-evaporation) :"27 s tring = "%s\n%s" % (string,fielddisplay(self, 'accumulation', 'accumulated snow [m/yr ice eq]'))28 s tring = "%s\n%s" % (string,fielddisplay(self, 'runoff', 'amount of ice melt lost from the ice column [m/yr ice eq]'))29 s tring = "%s\n%s" % (string,fielddisplay(self, 'evaporation', 'mount of ice lost to evaporative processes [m/yr ice eq]'))30 s tring = "%s\n%s" % (string,fielddisplay(self, 'isclimatology', 'repeat all forcings when past last forcing time (default false)'))31 s tring = "%s\n%s" % (string,fielddisplay(self, 'steps_per_step', 'number of smb steps per time step'))32 s tring = "%s\n%s" % (string,fielddisplay(self, 'averaging', 'averaging methods from short to long steps'))33 s tring = "%s\n\t\t%s" % (string,'0: Arithmetic (default)')34 s tring = "%s\n\t\t%s" % (string,'1: Geometric')35 s tring = "%s\n\t\t%s" % (string,'2: Harmonic')36 s tring = "%s\n%s" % (string,fielddisplay(self, 'requested_outputs', 'additional outputs requested'))37 return s tring33 s = ' surface forcings parameters (SMB = accumulation-runoff-evaporation):\n' 34 s += '{}\n'.format(fielddisplay(self, 'accumulation', 'accumulated snow [m/yr ice eq]')) 35 s += '{}\n'.format(fielddisplay(self, 'runoff', 'amount of ice melt lost from the ice column [m/yr ice eq]')) 36 s += '{}\n'.format(fielddisplay(self, 'evaporation', 'mount of ice lost to evaporative processes [m/yr ice eq]')) 37 s += '{}\n'.format(fielddisplay(self, 'isclimatology', 'repeat all forcings when past last forcing time (default false)')) 38 s += '{}\n'.format(fielddisplay(self, 'steps_per_step', 'number of smb steps per time step')) 39 s += '{}\n'.format(fielddisplay(self, 'averaging', 'averaging methods from short to long steps')) 40 s += '\t\t{}\n'.format('0: Arithmetic (default)') 41 s += '\t\t{}\n'.format('1: Geometric') 42 s += '\t\t{}\n'.format('2: Harmonic') 43 s += '{}\n'.format(fielddisplay(self, 'requested_outputs', 'additional outputs requested')) 44 return s 38 45 # }}} 39 46 … … 53 60 self.accumulation = np.zeros((md.mesh.numberofvertices)) 54 61 print(" no SMB.accumulation specified: values set as zero") 55 56 62 if np.all(np.isnan(self.runoff)): 57 63 self.runoff = np.zeros((md.mesh.numberofvertices)) … … 61 67 self.evaporation = np.zeros((md.mesh.numberofvertices)) 62 68 print(" no SMB.evaporation specified: values set as zero") 63 64 69 return self 65 70 # }}} … … 74 79 md = checkfield(md, 'fieldname', 'smb.runoff', 'size', [md.mesh.numberofvertices], 'NaN', 1, 'Inf', 1) 75 80 md = checkfield(md, 'fieldname', 'smb.evaporation', 'size', [md.mesh.numberofvertices], 'NaN', 1, 'Inf', 1) 76 77 81 md = checkfield(md, 'fieldname', 'smb.steps_per_step', '>=', 1, 'numel', [1]) 78 82 md = checkfield(md, 'fieldname', 'smb.averaging', 'numel', [1], 'values', [0, 1, 2]) 79 83 md = checkfield(md, 'fieldname', 'masstransport.requested_outputs', 'stringrow', 1) 80 84 md = checkfield(md, 'fieldname', 'smb.isclimatology', 'values', [0, 1]) 81 85 if self.isclimatology: 86 md = checkfield(md, 'fieldname', 'smb.accumulation', 'size', [md.mesh.numberofvertices + 1], 87 'message', 'accumulation must have md.mesh.numberofvertices+1 rows in order to force a climatology') 88 md = checkfield(md, 'fieldname', 'smb.runoff', 'size', [md.mesh.numberofvertices + 1], 'message', 'runoff must have md.mesh.numberofvertices+1 rows in order to force a climatology') 89 md = checkfield(md, 'fieldname', 'smb.evaporation', 'size', [md.mesh.numberofvertices + 1], 'message', 'evaporation must have md.mesh.numberofvertices+1 rows in order to force a climatology') 82 90 return md 83 91 # }}} -
issm/trunk-jpl/src/m/classes/SMBforcing.m
r24806 r25688 32 32 end % }}} 33 33 function list = defaultoutputs(self,md) % {{{ 34 35 34 list = {''}; 36 37 35 end % }}} 38 36 function self = extrude(self,md) % {{{ 39 40 37 self.mass_balance=project3d(md,'vector',self.mass_balance,'type','node'); 41 42 38 end % }}} 43 39 function self = initialize(self,md) % {{{ … … 50 46 end % }}} 51 47 function md = checkconsistency(self,md,solution,analyses) % {{{ 52 53 48 if (strcmp(solution,'TransientSolution') & md.transient.issmb == 0), return; end 54 55 49 if ismember('MasstransportAnalysis',analyses), 56 50 md = checkfield(md,'fieldname','smb.mass_balance','timeseries',1,'NaN',1,'Inf',1); -
issm/trunk-jpl/src/m/classes/SMBforcing.py
r24793 r25688 1 1 import numpy as np 2 3 from checkfield import checkfield 2 4 from fielddisplay import fielddisplay 3 from checkfield import checkfield5 from project3d import project3d 4 6 from WriteData import WriteData 5 from project3d import project3d6 7 7 8 8 9 class SMBforcing(object): 9 """ 10 SMBforcing Class definition 10 """SMBFORCING class definition 11 11 12 13 12 Usage: 13 SMB = SMBforcing() 14 14 """ 15 15 16 def __init__(self): # {{{ 17 self.mass_balance = float('NaN') 16 def __init__(self, *args): # {{{ 17 self.isclimatology = 0 18 self.mass_balance = np.nan 19 self.steps_per_step = 1 18 20 self.requested_outputs = [] 19 self.isclimatology = 020 self.steps_per_step = 121 21 self.averaging = 0 22 23 nargs = len(args) 24 if nargs == 0: 25 pass 26 else: 27 raise Exception('constructor not supported') 22 28 #}}} 23 29 24 30 def __repr__(self): # {{{ 25 s tring = " surface forcings parameters:"26 s tring = "%s\n%s" % (string,fielddisplay(self, 'mass_balance', 'surface mass balance [m/yr ice eq]'))27 s tring = "%s\n%s" % (string,fielddisplay(self, 'isclimatology', 'repeat all forcings when past last forcing time (default false)'))28 s tring = "%s\n%s" % (string,fielddisplay(self, 'steps_per_step', 'number of smb steps per time step'))29 s tring = "%s\n%s" % (string,fielddisplay(self, 'averaging', 'averaging methods from short to long steps'))30 s tring = "%s\n\t\t%s" % (string,'0: Arithmetic (default)')31 s tring = "%s\n\t\t%s" % (string,'1: Geometric')32 s tring = "%s\n\t\t%s" % (string,'2: Harmonic')33 s tring = "%s\n%s" % (string,fielddisplay(self, 'requested_outputs', 'additional outputs requested'))34 return s tring31 s = ' surface forcings parameters:\n' 32 s += '{}\n'.format(fielddisplay(self, 'mass_balance', 'surface mass balance [m/yr ice eq]')) 33 s += '{}\n'.format(fielddisplay(self, 'isclimatology', 'repeat all forcings when past last forcing time (default false)')) 34 s += '{}\n'.format(fielddisplay(self, 'steps_per_step', 'number of smb steps per time step')) 35 s += '{}\n'.format(fielddisplay(self, 'averaging', 'averaging methods from short to long steps')) 36 s += '\t\t{}\n'.format('0: Arithmetic (default)') 37 s += '\t\t{}\n'.format('1: Geometric') 38 s += '\t\t{}\n'.format('2: Harmonic') 39 s += '{}\n'.format(fielddisplay(self, 'requested_outputs', 'additional outputs requested')) 40 return s 35 41 #}}} 36 42 37 43 def extrude(self, md): # {{{ 38 39 44 self.mass_balance = project3d(md, 'vector', self.mass_balance, 'type', 'node') 40 45 return self … … 49 54 self.mass_balance = np.zeros((md.mesh.numberofvertices)) 50 55 print(" no SMBforcing.mass_balance specified: values set as zero") 51 52 56 return self 53 57 #}}} 54 58 55 59 def checkconsistency(self, md, solution, analyses): # {{{ 60 if solution == 'TransientSolution' and not md.transient.issmb: 61 return 56 62 if 'MasstransportAnalysis' in analyses: 57 63 md = checkfield(md, 'fieldname', 'smb.mass_balance', 'timeseries', 1, 'NaN', 1, 'Inf', 1) 58 59 64 if 'BalancethicknessAnalysis' in analyses: 60 65 md = checkfield(md, 'fieldname', 'smb.mass_balance', 'size', [md.mesh.numberofvertices], 'NaN', 1, 'Inf', 1) 61 62 66 md = checkfield(md, 'fieldname', 'smb.steps_per_step', '>=', 1, 'numel', [1]) 63 67 md = checkfield(md, 'fieldname', 'smb.averaging', 'numel', [1], 'values', [0, 1, 2]) 64 68 md = checkfield(md, 'fieldname', 'masstransport.requested_outputs', 'stringrow', 1) 65 69 md = checkfield(md, 'fieldname', 'smb.isclimatology', 'values', [0, 1]) 66 if (self.isclimatology > 0):70 if self.isclimatology: 67 71 md = checkfield(md, 'fieldname', 'smb.mass_balance', 'size', [md.mesh.numberofvertices + 1], 'message', 'mass_balance must have md.mesh.numberofvertices + 1 rows in order to force a climatology') 68 69 72 return md 70 73 # }}} … … 85 88 WriteData(fid, prefix, 'data', outputs, 'name', 'md.smb.requested_outputs', 'format', 'StringArray') 86 89 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'isclimatology', 'format', 'Boolean') 87 88 90 # }}} -
issm/trunk-jpl/src/m/classes/SMBpddSicopolis.py
r24793 r25688 1 1 import numpy as np 2 3 from checkfield import checkfield 2 4 from fielddisplay import fielddisplay 3 from checkfield import checkfield 5 from helpers import * 6 from MatlabFuncs import * 7 from project3d import project3d 4 8 from WriteData import WriteData 5 from project3d import project3d6 from MatlabFuncs import *7 from helpers import *8 9 9 10 10 11 class SMBpddSicopolis(object): 11 """ 12 SMBpddSicopolis Class definition 12 """SMBPDDSICOPOLIS class definition 13 13 14 14 Usage: 15 15 SMBpddSicopolis = SMBpddSicopolis() 16 """16 """ 17 17 18 def __init__(self ): # {{{19 self.precipitation = float('NaN')20 self.monthlytemperatures = float('NaN')21 self.temperature_anomaly = float('NaN')22 self.precipitation_anomaly = float('NaN')23 self.smb_corr = float('NaN')18 def __init__(self, *args): # {{{ 19 self.precipitation = np.nan 20 self.monthlytemperatures = np.nan 21 self.temperature_anomaly = np.nan 22 self.precipitation_anomaly = np.nan 23 self.smb_corr = np.nan 24 24 self.desfac = 0 25 self.s0p = float('NaN')26 self.s0t = float('NaN')25 self.s0p = np.nan 26 self.s0t = np.nan 27 27 self.rlaps = 0 28 28 self.isfirnwarming = 0 … … 31 31 self.requested_outputs = [] 32 32 33 self.setdefaultparameters() 33 nargs = len(args) 34 if nargs == 0: 35 self.setdefaultparameters() 36 else: 37 raise Exception('constructor not supported') 34 38 # }}} 35 39 36 40 def __repr__(self): # {{{ 37 string = ' surface forcings parameters:' 38 string += '\n SICOPOLIS PDD scheme (Calov & Greve, 2005) :' 39 40 string = "%s\n%s" % (string, fielddisplay(self, 'monthlytemperatures', 'monthly surface temperatures [K]')) 41 string = "%s\n%s" % (string, fielddisplay(self, 'precipitation', 'monthly surface precipitation [m/yr water eq]')) 42 string = "%s\n%s" % (string, fielddisplay(self, 'temperature_anomaly', 'anomaly to monthly reference temperature (additive [K])')) 43 string = "%s\n%s" % (string, fielddisplay(self, 'precipitation_anomaly', 'anomaly to monthly precipitation (multiplicative, e.g. q = q0*exp(0.070458*DeltaT) after Huybrechts (2002)) [no unit])')) 44 string = "%s\n%s" % (string, fielddisplay(self, 'smb_corr', 'correction of smb after PDD call [m/a]')) 45 string = "%s\n%s" % (string, fielddisplay(self, 's0p', 'should be set to elevation from precip source (between 0 and a few 1000s m, default is 0) [m]')) 46 string = "%s\n%s" % (string, fielddisplay(self, 's0t', 'should be set to elevation from temperature source (between 0 and a few 1000s m, default is 0) [m]')) 47 string = "%s\n%s" % (string, fielddisplay(self, 'rlaps', 'present day lapse rate (default is 7.4 degree/km)')) 48 string = "%s\n%s" % (string, fielddisplay(self, 'desfac', 'desertification elevation factor (default is -log(2.0)/1000)')) 49 string = "%s\n%s" % (string, fielddisplay(self, 'isfirnwarming', 'is firnwarming (Reeh 1991) activated (0 or 1, default is 1)')) 50 string = "%s\n%s" % (string, fielddisplay(self, 'steps_per_step', 'number of smb steps per time step')) 51 string = "%s\n%s" % (string, fielddisplay(self, 'averaging', 'averaging methods from short to long steps')) 52 string = "%s\n\t\t%s" % (string, '0: Arithmetic (default)') 53 string = "%s\n\t\t%s" % (string, '1: Geometric') 54 string = "%s\n\t\t%s" % (string, '2: Harmonic') 55 56 string = "%s\n%s" % (string, fielddisplay(self, 'requested_outputs', 'additional outputs requested (TemperaturePDD, SmbAccumulation, SmbMelt)')) 57 # }}} 58 59 @staticmethod 60 def SMBpddSicopolis(*args): # {{{ 61 nargin = len(args) 62 63 if nargin == 0: 64 return SMBpddSicopolis() 65 else: 66 raise RuntimeError('SMBpddSicopolis: constructor not supported') 41 s = ' surface forcings parameters:\n' 42 s += ' SICOPOLIS PDD scheme (Calov & Greve, 2005):\n' 43 s += '{}\n'.format(fielddisplay(self, 'monthlytemperatures', 'monthly surface temperatures [K]')) 44 s += '{}\n'.format(fielddisplay(self, 'precipitation', 'monthly surface precipitation [m/yr water eq]')) 45 s += '{}\n'.format(fielddisplay(self, 'temperature_anomaly', 'anomaly to monthly reference temperature (additive [K])')) 46 s += '{}\n'.format(fielddisplay(self, 'precipitation_anomaly', 'anomaly to monthly precipitation (multiplicative, e.g. q = q0*exp(0.070458*DeltaT) after Huybrechts (2002)) [no unit])')) 47 s += '{}\n'.format(fielddisplay(self, 'smb_corr', 'correction of smb after PDD call [m/a]')) 48 s += '{}\n'.format(fielddisplay(self, 's0p', 'should be set to elevation from precip source (between 0 and a few 1000s m, default is 0) [m]')) 49 s += '{}\n'.format(fielddisplay(self, 's0t', 'should be set to elevation from temperature source (between 0 and a few 1000s m, default is 0) [m]')) 50 s += '{}\n'.format(fielddisplay(self, 'rlaps', 'present day lapse rate (default is 7.4 degree/km)')) 51 s += '{}\n'.format(fielddisplay(self, 'desfac', 'desertification elevation factor (default is -log(2.0)/1000)')) 52 s += '{}\n'.format(fielddisplay(self, 'isfirnwarming', 'is firnwarming (Reeh 1991) activated (0 or 1, default is 1)')) 53 s += '{}\n'.format(fielddisplay(self, 'steps_per_step', 'number of smb steps per time step')) 54 s += '{}\n'.format(fielddisplay(self, 'averaging', 'averaging methods from short to long steps')) 55 s += '\t\t{}\n'.format('0: Arithmetic (default)') 56 s += '\t\t{}\n'.format('1: Geometric') 57 s += '\t\t{}\n'.format('2: Harmonic') 58 s += '{}\n'.format(fielddisplay(self, 'requested_outputs', 'additional outputs requested (TemperaturePDD, SmbAccumulation, SmbMelt)')) 59 return s 67 60 # }}} 68 61 … … 83 76 84 77 def initialize(self, md): # {{{ 85 86 78 if np.isnan(self.s0p): 87 79 self.s0p = np.zeros((md.mesh.numberofvertices, )) … … 103 95 self.smb_corr = np.zeros((md.mesh.numberofvertices, )) 104 96 print(' no SMBpddSicopolis.smb_corr specified: values set as zero') 97 return self 105 98 # }}} 106 99 … … 109 102 self.desfac = -np.log(2.0) / 1000 110 103 self.rlaps = 7.4 111 104 return self 112 105 # }}} 113 106 114 107 def checkconsistency(self, md, solution, analyses): # {{{ 115 if (strcmp(solution, 'TransientSolution') and md.transient.issmb == 0):108 if solution == 'TransientSolution' and not md.transient.issmb: 116 109 return 117 118 110 if 'MasstransportAnalysis' in analyses: 119 111 md = checkfield(md, 'fieldname', 'smb.desfac', '<=', 1, 'numel', 1) … … 123 115 md = checkfield(md, 'fieldname', 'smb.monthlytemperatures', 'NaN', 1, 'Inf', 1, 'size', [md.mesh.numberofvertices, 12]) 124 116 md = checkfield(md, 'fieldname', 'smb.precipitation', 'NaN', 1, 'Inf', 1, 'size', [md.mesh.numberofvertices, 12]) 125 126 117 md = checkfield(md, 'fieldname', 'smb.steps_per_step', '>=', 1, 'numel', [1]) 127 118 md = checkfield(md, 'fieldname', 'smb.averaging', 'numel', [1], 'values', [0, 1, 2]) 128 119 md = checkfield(md, 'fieldname', 'smb.requested_outputs', 'stringrow', 1) 129 130 120 return md 131 121 # }}} 132 122 133 123 def marshall(self, prefix, md, fid): # {{{ 134 135 124 yts = md.constants.yts 136 137 125 WriteData(fid, prefix, 'name', 'md.smb.model', 'data', 10, 'format', 'Integer') 138 139 126 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'isfirnwarming', 'format', 'Boolean') 140 127 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'desfac', 'format', 'Double') … … 142 129 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 's0t', 'format', 'DoubleMat', 'mattype', 1) 143 130 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'rlaps', 'format', 'Double') 144 145 131 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'monthlytemperatures', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', md.constants.yts) 146 132 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'precipitation', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1. / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts) … … 159 145 160 146 WriteData(fid, prefix, 'data', outputs, 'name', 'md.smb.requested_outputs', 'format', 'StringArray') 161 162 147 # }}} -
issm/trunk-jpl/src/m/classes/basalforcings.py
r24213 r25688 1 import numpy as np 2 3 from checkfield import checkfield 1 4 from fielddisplay import fielddisplay 2 5 from project3d import project3d 3 from checkfield import checkfield4 6 from WriteData import WriteData 5 import numpy as np6 7 7 8 8 9 class basalforcings(object): 9 """ 10 BASAL FORCINGS class definition 10 """BASAL FORCINGS class definition 11 11 12 13 12 Usage: 13 basalforcings = basalforcings() 14 14 """ 15 15 16 16 def __init__(self): # {{{ 17 self.groundedice_melting_rate = float('NaN')18 self.floatingice_melting_rate = float('NaN')19 self.geothermalflux = float('NaN')17 self.groundedice_melting_rate = np.nan 18 self.floatingice_melting_rate = np.nan 19 self.geothermalflux = np.nan 20 20 21 #set defaults22 21 self.setdefaultparameters() 23 24 22 #}}} 25 23 26 24 def __repr__(self): # {{{ 27 string = " basal forcings parameters:" 28 29 string = "%s\n%s" % (string, fielddisplay(self, "groundedice_melting_rate", "basal melting rate (positive if melting) [m / yr]")) 30 string = "%s\n%s" % (string, fielddisplay(self, "floatingice_melting_rate", "basal melting rate (positive if melting) [m / yr]")) 31 string = "%s\n%s" % (string, fielddisplay(self, "geothermalflux", "geothermal heat flux [W / m^2]")) 32 return string 25 s = ' basal forcings parameters:\n' 26 s += '{}\n'.format(fielddisplay(self, "groundedice_melting_rate", "basal melting rate (positive if melting) [m / yr]")) 27 s += '{}\n'.format(fielddisplay(self, "floatingice_melting_rate", "basal melting rate (positive if melting) [m / yr]")) 28 s += '{}\n'.format(fielddisplay(self, "geothermalflux", "geothermal heat flux [W / m^2]")) 29 return s 33 30 #}}} 34 31 … … 36 33 self.groundedice_melting_rate = project3d(md, 'vector', self.groundedice_melting_rate, 'type', 'node', 'layer', 1) 37 34 self.floatingice_melting_rate = project3d(md, 'vector', self.floatingice_melting_rate, 'type', 'node', 'layer', 1) 38 self.geothermalflux = project3d(md, 'vector', self.geothermalflux, 'type', 'node', 'layer', 1) #bedrock only gets geothermal flux35 self.geothermalflux = project3d(md, 'vector', self.geothermalflux, 'type', 'node', 'layer', 1) # Bedrock only gets geothermal flux 39 36 return self 40 37 #}}} … … 42 39 def initialize(self, md): # {{{ 43 40 if np.all(np.isnan(self.groundedice_melting_rate)): 44 self.groundedice_melting_rate = np.zeros((md.mesh.numberofvertices ))41 self.groundedice_melting_rate = np.zeros((md.mesh.numberofvertices, )) 45 42 print(" no basalforcings.groundedice_melting_rate specified: values set as zero") 46 47 43 if np.all(np.isnan(self.floatingice_melting_rate)): 48 self.floatingice_melting_rate = np.zeros((md.mesh.numberofvertices ))44 self.floatingice_melting_rate = np.zeros((md.mesh.numberofvertices, )) 49 45 print(" no basalforcings.floatingice_melting_rate specified: values set as zero") 50 #if np.all(np.isnan(self.geothermalflux)):51 #self.geothermalflux = np.zeros((md.mesh.numberofvertices))52 #print " no basalforcings.geothermalflux specified: values set as zero"53 54 46 return self 55 47 #}}} … … 60 52 61 53 def checkconsistency(self, md, solution, analyses): # {{{ 62 63 if 'MasstransportAnalysis' in analyses and not (solution == 'TransientSolution' and not md.transient.ismasstransport): 54 if 'MasstransportAnalysis' in analyses and not solution == 'TransientSolution' and not md.transient.ismasstransport: 64 55 md = checkfield(md, 'fieldname', 'basalforcings.groundedice_melting_rate', 'NaN', 1, 'Inf', 1, 'timeseries', 1) 65 56 md = checkfield(md, 'fieldname', 'basalforcings.floatingice_melting_rate', 'NaN', 1, 'Inf', 1, 'timeseries', 1) 66 67 57 if 'BalancethicknessAnalysis' in analyses: 68 58 md = checkfield(md, 'fieldname', 'basalforcings.groundedice_melting_rate', 'NaN', 1, 'Inf', 1, 'size', [md.mesh.numberofvertices]) 69 59 md = checkfield(md, 'fieldname', 'basalforcings.floatingice_melting_rate', 'NaN', 1, 'Inf', 1, 'size', [md.mesh.numberofvertices]) 70 71 if 'ThermalAnalysis' in analyses and not (solution == 'TransientSolution' and not md.transient.isthermal): 60 if 'ThermalAnalysis' in analyses and not solution == 'TransientSolution' and not md.transient.isthermal: 72 61 md = checkfield(md, 'fieldname', 'basalforcings.groundedice_melting_rate', 'NaN', 1, 'Inf', 1, 'timeseries', 1) 73 62 md = checkfield(md, 'fieldname', 'basalforcings.floatingice_melting_rate', 'NaN', 1, 'Inf', 1, 'timeseries', 1) 74 63 md = checkfield(md, 'fieldname', 'basalforcings.geothermalflux', 'NaN', 1, 'Inf', 1, 'timeseries', 1, '>=', 0) 75 76 64 return md 77 65 # }}} 78 66 79 67 def marshall(self, prefix, md, fid): # {{{ 80 81 68 yts = md.constants.yts 82 83 69 WriteData(fid, prefix, 'name', 'md.basalforcings.model', 'data', 1, 'format', 'Integer') 84 70 WriteData(fid, prefix, 'object', self, 'fieldname', 'groundedice_melting_rate', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1. / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', md.constants.yts) -
issm/trunk-jpl/src/m/classes/dsl.py
r25169 r25688 8 8 9 9 class dsl(object): 10 ''' 11 DSL - slass definition 10 """DSL - slass definition 12 11 13 14 15 '''12 Usage: 13 dsl = dsl() 14 """ 16 15 17 16 def __init__(self): #{{{ … … 23 22 24 23 def __repr__(self): #{{{ 25 s = " dsl parameters:" 26 s = "%s\n%s" % (s, fielddisplay(self, 'global_average_thermosteric_sea_level_change', 'corresponds to zostoga field in CMIP5 archives. Specified as a temporally variable global rate (mm/yr)')) 27 s = "%s\n%s" % (s, fielddisplay(self, 'sea_surface_height_change_above_geoid', 'corresponds to zos field in CMIP5 archives. Spatial average is 0. Specified as a spatio-temporally variable rate (mm/yr)')) 28 s = "%s\n%s" % (s, fielddisplay(self, 'sea_water_pressure_change_at_sea_floor', 'corresponds to bpo field in CMIP5 archives. Specified as a spatio-temporally variable rate (in Pa/yr)')) 29 s = "%s\n%s" % (s, fielddisplay(self, 'compute_fingerprints', 'do we use the sea water pressure change to compute fingerprints and correct sea_surface_height_change_above_geoid')) 30 24 s = ' dsl parameters:\n' 25 s += '{}\n'.format(fielddisplay(self, 'global_average_thermosteric_sea_level_change', 'corresponds to zostoga field in CMIP5 archives. Specified as a temporally variable global rate (mm/yr)')) 26 s += '{}\n'.format(fielddisplay(self, 'sea_surface_height_change_above_geoid', 'corresponds to zos field in CMIP5 archives. Spatial average is 0. Specified as a spatio-temporally variable rate (mm/yr)')) 27 s += '{}\n'.format(fielddisplay(self, 'sea_water_pressure_change_at_sea_floor', 'corresponds to bpo field in CMIP5 archives. Specified as a spatio-temporally variable rate (in Pa/yr)')) 28 s += '{}\n'.format(fielddisplay(self, 'compute_fingerprints', 'do we use the sea water pressure change to compute fingerprints and correct sea_surface_height_change_above_geoid')) 31 29 return s 32 30 #}}} … … 43 41 44 42 def checkconsistency(self, md, solution, analyses): #{{{ 45 # Early retu n43 # Early return 46 44 if 'SealevelriseAnalysis' not in analyses: 47 45 return md 48 49 46 if solution == 'TransientSolution' and md.transient.isslr == 0: 50 47 return md 51 52 48 md = checkfield(md, 'fieldname', 'dsl.global_average_thermosteric_sea_level_change', 'NaN', 1, 'Inf', 1) 53 49 md = checkfield(md, 'fieldname', 'dsl.sea_surface_height_change_above_geoid', 'NaN', 1, 'Inf', 1, 'timeseries', 1) 54 50 md = checkfield(md, 'fieldname', 'dsl.sea_water_pressure_change_at_sea_floor', 'NaN', 1, 'Inf', 1, 'timeseries', 1) 55 51 md = checkfield(md, 'fieldname', 'dsl.compute_fingerprints', 'NaN', 1, 'Inf', 1, 'values', [0, 1]) 56 57 52 if self.compute_fingerprints: 58 # check geodetic flag of slr is on:59 if md.slr.geodetic == 0:53 # Check if geodetic flag of slr is on 54 if not md.slr.geodetic: 60 55 raise RuntimeError('DSL checkconsistency error message: if bottom pressure fingerprints computations are requested, slr class should have geodetic flag on') 61 56 return md -
issm/trunk-jpl/src/m/classes/dslmme.py
r25343 r25688 8 8 9 9 class dslmme(object): 10 ''' 11 DSLMME class definition 10 """DSLMME class definition 12 11 13 14 15 '''12 Usage: 13 dsl = dslmme() #dynamic sea level class based on a multi-model ensemble of CMIP5 outputs 14 """ 16 15 17 16 def __init__(self, *args): #{{{ … … 37 36 s += '{}\n'.format(fielddisplay(self, 'sea_water_pressure_change_at_sea_floor', 'corresponds to bpo fields in CMIP5 archives. Specified as a spatio-temporally variable rate (in mm/yr) for each ensemble.')) 38 37 s += '{}\n'.format(fielddisplay(self, 'compute_fingerprints', 'do we use the sea water pressure change to compute fingerprints and correct sea_surface_height_change_above_geoid')) 39 40 38 return s 41 39 #}}} 42 40 43 def setdefaultparameters(self): # 44 return 41 def setdefaultparameters(self): #{{{ 42 return self 45 43 #}}} 46 44 47 45 def checkconsistency(self, md, solution, analyses): # {{{ 48 if ('SealevelriseAnalysis' not in analyses) or (solution == 'TransientSolution' and md.transient.isslr == 0):46 if ('SealevelriseAnalysis' not in analyses) or (solution == 'TransientSolution' and not md.transient.isslr): 49 47 return md 50 51 48 for i in range(len(self.global_average_thermosteric_sea_level_change)): 52 49 md = checkfield(md, 'field', self.global_average_thermosteric_sea_level_change[i], 'NaN', 1, 'Inf', 1) 53 50 md = checkfield(md, 'field', self.sea_surface_height_change_above_geoid[i], 'NaN', 1, 'Inf', 1, 'timeseries', 1) 54 51 md = checkfield(md, 'field', self.sea_water_pressure_change_at_sea_floor[i], 'NaN', 1, 'Inf', 1, 'timeseries', 1) 55 56 52 md = checkfield(md, 'field', self.modelid, 'NaN', 1, 'Inf', 1, '>=', 1, '<=',len(self.global_average_thermosteric_sea_level_change)) 57 58 53 if self.compute_fingerprints: 59 54 #check geodetic flag of slr is on 60 if md.solidearth.settings.computesealevelchange == 0,55 if not md.solidearth.settings.computesealevelchange: 61 56 raise Exception('DSL checkconsistency error message: if bottom pressure fingerprints computations are requested, slr class should have geodetic flag on') 62 63 57 return md 64 58 #}}} -
issm/trunk-jpl/src/m/classes/flowequation.m
r25661 r25688 13 13 isFS = 0; 14 14 isNitscheBC = 0; 15 15 FSNitscheGamma = 1e6; 16 16 fe_SSA = ''; 17 17 fe_HO = ''; -
issm/trunk-jpl/src/m/classes/flowequation.py
r25626 r25688 23 23 self.isFS = 0 24 24 self.isNitscheBC = 0 25 self.FSNitscheGamma = 1e -625 self.FSNitscheGamma = 1e6 26 26 self.fe_SSA = '' 27 27 self.fe_HO = '' … … 32 32 self.augmented_lagrangian_rholambda = 1. 33 33 self.XTH_theta = 0. 34 self.vertex_equation = float('NaN') 35 self.element_equation = float('NaN') 36 self.borderSSA = float('NaN') 37 self.borderHO = float('NaN') 38 self.borderFS = float('NaN') 39 40 #set defaults 34 self.vertex_equation = np.nan 35 self.element_equation = np.nan 36 self.borderSSA = np.nan 37 self.borderHO = np.nan 38 self.borderFS = np.nan 39 41 40 self.setdefaultparameters() 42 43 41 #}}} 44 42 45 43 def __repr__(self): # {{{ 46 44 s = ' flow equation parameters:\n' 47 s += "{}\n".format(fielddisplay(self, 'isSIA', "is the Shallow Ice Approximation (SIA) used?")) 48 s += "{}\n".format(fielddisplay(self, 'isSSA', "is the Shelfy-Stream Approximation (SSA) used?")) 49 s += "{}\n".format(fielddisplay(self, 'isL1L2', "are L1L2 equations used?")) 50 s += "{}\n".format(fielddisplay(self, 'isMLHO', "are Mono-layer Higher-Order equations used?")) 51 s += "{}\n".format(fielddisplay(self, 'isHO', "is the Higher-Order (HO) approximation used?")) 52 s += "{}\n".format(fielddisplay(self, 'isFS', "are the Full-FS (FS) equations used?")) 53 s += "{}\n".format(fielddisplay(self, 'isNitscheBC', "is weakly imposed condition used?")) 54 s += "{}\n".format(fielddisplay(self, 'FSNitscheGamma', "Gamma value for the Nitsche term (default: 1e6)")) 55 s += "{}\n".format(fielddisplay(self, 'fe_SSA', "Finite Element for SSA: 'P1', 'P1bubble' 'P1bubblecondensed' 'P2'")) 56 s += "{}\n".format(fielddisplay(self, 'fe_HO', "Finite Element for HO: 'P1', 'P1bubble', 'P1bubblecondensed', 'P1xP2', 'P2xP1', 'P2', 'P2bubble', 'P1xP3', 'P2xP4'")) 57 s += "{}\n".format(fielddisplay(self, 'fe_FS', "Finite Element for FS: 'P1P1' (debugging only) 'P1P1GLS' 'MINIcondensed' 'MINI' 'TaylorHood' 'LATaylorHood' 'XTaylorHood'")) 58 s += "{}\n".format(fielddisplay(self, 'vertex_equation', "flow equation for each vertex")) 59 s += "{}\n".format(fielddisplay(self, 'element_equation', "flow equation for each element")) 60 s += "{}\n".format(fielddisplay(self, 'borderSSA', "vertices on SSA's border (for tiling)")) 61 s += "{}\n".format(fielddisplay(self, 'borderHO', "vertices on HO's border (for tiling)")) 62 s += "{}".format(fielddisplay(self, 'borderFS', "vertices on FS' border (for tiling)")) 45 s += '{}\n'.format(fielddisplay(self, 'isSIA', "is the Shallow Ice Approximation (SIA) used?")) 46 s += '{}\n'.format(fielddisplay(self, 'isSSA', "is the Shelfy-Stream Approximation (SSA) used?")) 47 s += '{}\n'.format(fielddisplay(self, 'isL1L2', "are L1L2 equations used?")) 48 s += '{}\n'.format(fielddisplay(self, 'isMLHO', "are Mono-layer Higher-Order equations used?")) 49 s += '{}\n'.format(fielddisplay(self, 'isHO', "is the Higher-Order (HO) approximation used?")) 50 s += '{}\n'.format(fielddisplay(self, 'isFS', "are the Full-FS (FS) equations used?")) 51 s += '{}\n'.format(fielddisplay(self, 'isNitscheBC', "is weakly imposed condition used?")) 52 s += '{}\n'.format(fielddisplay(self, 'FSNitscheGamma', "Gamma value for the Nitsche term (default: 1e6)")) 53 s += '{}\n'.format(fielddisplay(self, 'fe_SSA', "Finite Element for SSA: 'P1', 'P1bubble' 'P1bubblecondensed' 'P2'")) 54 s += '{}\n'.format(fielddisplay(self, 'fe_HO', "Finite Element for HO: 'P1', 'P1bubble', 'P1bubblecondensed', 'P1xP2', 'P2xP1', 'P2', 'P2bubble', 'P1xP3', 'P2xP4'")) 55 s += '{}\n'.format(fielddisplay(self, 'fe_FS', "Finite Element for FS: 'P1P1' (debugging only) 'P1P1GLS' 'MINIcondensed' 'MINI' 'TaylorHood' 'LATaylorHood' 'XTaylorHood'")) 56 s += '{}\n'.format(fielddisplay(self, 'vertex_equation', "flow equation for each vertex")) 57 s += '{}\n'.format(fielddisplay(self, 'element_equation', "flow equation for each element")) 58 s += '{}\n'.format(fielddisplay(self, 'borderSSA', "vertices on SSA's border (for tiling)")) 59 s += '{}\n'.format(fielddisplay(self, 'borderHO', "vertices on HO's border (for tiling)")) 60 s += '{}\n'.format(fielddisplay(self, 'borderFS', "vertices on FS' border (for tiling)")) 61 return s 62 #}}} 63 63 64 return s 64 def setdefaultparameters(self): # {{{ 65 # P1 for SSA 66 self.fe_SSA = 'P1' 67 68 # P1 for HO 69 self.fe_HO = 'P1' 70 71 # MINI condensed element for FS by default 72 self.fe_FS = 'MINIcondensed' 73 return self 65 74 #}}} 66 75 … … 74 83 #}}} 75 84 76 def setdefaultparameters(self): # {{{77 #P1 for SSA78 self.fe_SSA = 'P1'79 80 #P1 for HO81 self.fe_HO = 'P1'82 83 #MINI condensed element for FS by default84 self.fe_FS = 'MINIcondensed'85 86 return self87 #}}}88 89 85 def checkconsistency(self, md, solution, analyses): # {{{ 90 91 #Early return 86 # Early return 92 87 if ('StressbalanceAnalysis' not in analyses and 'StressbalanceSIAAnalysis' not in analyses) or (solution == 'TransientSolution' and not md.transient.isstressbalance): 93 88 return md 94 95 89 md = checkfield(md, 'fieldname', 'flowequation.isSIA', 'numel', [1], 'values', [0, 1]) 96 90 md = checkfield(md, 'fieldname', 'flowequation.isSSA', 'numel', [1], 'values', [0, 1]) … … 122 116 md = checkfield(md, 'fieldname', 'flowequation.element_equation', 'size', [md.mesh.numberofelements], 'values', np.arange(0, 9 + 1)) 123 117 else: 124 raise RuntimeError(' mesh type not supported yet')118 raise RuntimeError('Case not supported yet') 125 119 if not (self.isSIA or self.isSSA or self.isL1L2 or self.isMLHO or self.isHO or self.isFS): 126 120 md.checkmessage("no element types set for this model") 127 128 121 if 'StressbalanceSIAAnalysis' in analyses: 129 122 if any(self.element_equation == 1): 130 123 if np.any(np.logical_and(self.vertex_equation, md.mask.ocean_levelset)): 131 124 print("\n !!! Warning: SIA's model is not consistent on ice shelves !!!\n") 132 133 125 return md 134 126 # }}} … … 154 146 WriteData(fid, prefix, 'object', self, 'fieldname', 'borderHO', 'format', 'DoubleMat', 'mattype', 1) 155 147 WriteData(fid, prefix, 'object', self, 'fieldname', 'borderFS', 'format', 'DoubleMat', 'mattype', 1) 156 # convert approximations to enums148 # Convert approximations to enums 157 149 WriteData(fid, prefix, 'data', self.vertex_equation, 'name', 'md.flowequation.vertex_equation', 'format', 'DoubleMat', 'mattype', 1) 158 150 WriteData(fid, prefix, 'data', self.element_equation, 'name', 'md.flowequation.element_equation', 'format', 'DoubleMat', 'mattype', 2) 159 160 151 # }}} -
issm/trunk-jpl/src/m/classes/friction.m
r25499 r25688 66 66 67 67 otherwise 68 error('not supported yet'); 68 error('not supported yet'); 69 69 end 70 70 end % }}} -
issm/trunk-jpl/src/m/classes/friction.py
r25499 r25688 21 21 self.effective_pressure = np.nan 22 22 self.effective_pressure_limit = 0 23 24 #set defaults25 23 self.setdefaultparameters() 26 24 #}}} 27 25 28 26 def __repr__(self): # {{{ 29 s = "Basal shear stress parameters: Sigma_b = coefficient^2 * Neff ^r * |u_b|^(s - 1) * u_b, \n(effective stress Neff = rho_ice * g * thickness + rho_water * g * base, r = q / p and s = 1 / p)\n"30 s = "{}\n".format(fielddisplay(self, "coefficient", "friction coefficient [SI]"))31 s = "{}\n".format(fielddisplay(self, "p", "p exponent"))32 s = "{}\n".format(fielddisplay(self, "q", "qexponent"))33 s = "{}\n".format(fielddisplay(self, 'coupling', 'Coupling flag 0: uniform sheet (negative pressure ok, default), 1: ice pressure only, 2: water pressure assuming uniform sheet (no negative pressure), 3: use provided effective_pressure, 4: used coupled model (not implemented yet)'))34 s = "{}\n".format(fielddisplay(self, 'effective_pressure', 'Effective Pressure for the forcing if not coupled [Pa]'))35 s = "{}\n".format(fielddisplay(self, 'effective_pressure_limit', 'Neff do not allow to fall below a certain limit: effective_pressure_limit * rho_ice * g * thickness (default 0)'))36 27 s = 'Basal shear stress parameters: Sigma_b = coefficient^2 * Neff ^r * |u_b|^(s - 1) * u_b,\n' 28 s += '(effective stress Neff = rho_ice * g * thickness + rho_water * g * base, r = q / p and s = 1 / p)\n' 29 s += '{}\n'.format(fielddisplay(self, "coefficient", "friction coefficient [SI]")) 30 s += '{}\n'.format(fielddisplay(self, "p", "p exponent")) 31 s += '{}\n'.format(fielddisplay(self, "q", "q exponent")) 32 s += '{}\n'.format(fielddisplay(self, 'coupling', 'Coupling flag 0: uniform sheet (negative pressure ok, default), 1: ice pressure only, 2: water pressure assuming uniform sheet (no negative pressure), 3: use provided effective_pressure, 4: used coupled model (not implemented yet)')) 33 s += '{}\n'.format(fielddisplay(self, 'effective_pressure', 'Effective Pressure for the forcing if not coupled [Pa]')) 34 s += '{}\n'.format(fielddisplay(self, 'effective_pressure_limit', 'Neff do not allow to fall below a certain limit: effective_pressure_limit * rho_ice * g * thickness (default 0)')) 37 35 return s 38 36 #}}} … … 40 38 def setdefaultparameters(self): # {{{ 41 39 self.effective_pressure_limit = 0 42 43 40 return self 44 41 #}}} … … 48 45 self.p = project3d(md, 'vector', self.p, 'type', 'element') 49 46 self.q = project3d(md, 'vector', self.q, 'type', 'element') 50 #if self.coupling == 0: #doesnt work with empty loop, so just skip it?47 # If self.coupling == 0: #doesnt work with empty loop, so just skip it? 51 48 if self.coupling in[3, 4]: 52 49 self.effective_pressure = project3d(md, 'vector', self.effective_pressure, 'type', 'node', 'layer', 1) … … 62 59 63 60 def checkconsistency(self, md, solution, analyses): # {{{ 64 # Early return61 # Early return 65 62 if 'StressbalanceAnalysis' not in analyses and 'ThermalAnalysis' not in analyses: 66 63 return md 67 if solution == 'TransientSolu ition' and not md.transient.isstressbalance and not md.transient.isthermal:64 if solution == 'TransientSolution' and not md.transient.isstressbalance and not md.transient.isthermal: 68 65 return md 69 70 66 md = checkfield(md, 'fieldname', 'friction.coefficient', 'timeseries', 1, 'NaN', 1, 'Inf', 1) 71 67 md = checkfield(md, 'fieldname', 'friction.q', 'NaN', 1, 'Inf', 1, 'size', [md.mesh.numberofelements]) … … 77 73 elif self.coupling > 4: 78 74 raise ValueError('not supported yet') 79 80 75 return md 81 76 # }}} … … 83 78 def marshall(self, prefix, md, fid): # {{{ 84 79 WriteData(fid, prefix, 'name', 'md.friction.law', 'data', 1, 'format', 'Integer') 85 86 80 if type(self.coefficient) in [np.ndarray] and (self.coefficient.shape[0] == md.mesh.numberofvertices or self.coefficient.shape[0] == (md.mesh.numberofvertices + 1)): 87 81 mattype = 1 … … 90 84 mattype = 2 91 85 tsl = md.mesh.numberofelements 92 93 86 WriteData(fid, prefix, 'object', self, 'fieldname', 'coefficient', 'format', 'DoubleMat', 'mattype', mattype, 'timeserieslength', tsl + 1, 'yts', md.constants.yts) 94 87 WriteData(fid, prefix, 'object', self, 'fieldname', 'p', 'format', 'DoubleMat', 'mattype', 2) -
issm/trunk-jpl/src/m/classes/frictioncoulomb.py
r25499 r25688 23 23 self.effective_pressure_limit = 0 24 24 25 #set defaults26 25 self.setdefaultparameters() 27 26 #}}} 28 27 29 28 def __repr__(self): # {{{ 30 s = "Basal shear stress parameters: Sigma_b = min(coefficient^2 * Neff ^r * |u_b|^(s - 1) * u_b, \n coefficientcoulomb^2 * rho_i * g * (h - h_f)), (effective stress Neff = rho_ice * g * thickness + rho_water * g * bed, r = q / p and s = 1 / p).\n"31 s = "{}\n".format(fielddisplay(self, "coefficient", "power law (Weertman) friction coefficient [SI]"))32 s = "{}\n".format(fielddisplay(self, "coefficientcoulomb", "Coulombfriction coefficient [SI]"))33 s = "{}\n".format(fielddisplay(self, "p", "p exponent"))34 s = "{}\n".format(fielddisplay(self, "q", "qexponent"))35 s = "{}\n".format(fielddisplay(self, 'coupling', 'Coupling flag: 0 for default, 1 for forcing(provide md.friction.effective_pressure) and 2 for coupled(not implemented yet)'))36 s = "{}\n".format(fielddisplay(self, 'effective_pressure', 'Effective Pressure for the forcing if not coupled [Pa]'))37 s = "{}\n".format(fielddisplay(self, 'effective_pressure_limit', 'Neff do not allow to fall below a certain limit: effective_pressure_limit * rho_ice * g * thickness (default 0)'))38 29 s = 'Basal shear stress parameters: Sigma_b = min(coefficient^2 * Neff ^r * |u_b|^(s - 1) * u_b,\n' 30 s += 'coefficientcoulomb^2 * rho_i * g * (h - h_f)), (effective stress Neff = rho_ice * g * thickness + rho_water * g * bed, r = q / p and s = 1 / p).\n' 31 s += '{}\n'.format(fielddisplay(self, "coefficient", "power law (Weertman) friction coefficient [SI]")) 32 s += '{}\n'.format(fielddisplay(self, "coefficientcoulomb", "Coulomb friction coefficient [SI]")) 33 s += '{}\n'.format(fielddisplay(self, "p", "p exponent")) 34 s += '{}\n'.format(fielddisplay(self, "q", "q exponent")) 35 s += '{}\n'.format(fielddisplay(self, 'coupling', 'Coupling flag: 0 for default, 1 for forcing(provide md.friction.effective_pressure) and 2 for coupled(not implemented yet)')) 36 s += '{}\n'.format(fielddisplay(self, 'effective_pressure', 'Effective Pressure for the forcing if not coupled [Pa]')) 37 s += '{}\n'.format(fielddisplay(self, 'effective_pressure_limit', 'Neff do not allow to fall below a certain limit: effective_pressure_limit * rho_ice * g * thickness (default 0)')) 39 38 return s 40 39 #}}} … … 42 41 def setdefaultparameters(self): # {{{ 43 42 self.effective_pressure_limit = 0 44 45 43 return self 46 44 #}}} … … 57 55 elif self.coupling > 2: 58 56 raise ValueError('not supported yet') 59 60 57 return self 61 58 #}}} 62 59 def checkconsistency(self, md, solution, analyses): # {{{ 63 # Early return60 # Early return 64 61 if 'StressbalanceAnalysis' not in analyses and 'ThermalAnalysis' not in analyses: 65 62 return md 66 67 63 md = checkfield(md, 'fieldname', 'friction.coefficient', 'timeseries', 1, 'NaN', 1, 'Inf', 1) 68 64 md = checkfield(md, 'fieldname', 'friction.coefficientcoulomb', 'timeseries', 1, 'NaN', 1, 'Inf', 1) … … 77 73 elif self.coupling > 2: 78 74 raise ValueError('not supported yet') 79 80 75 return md 81 76 # }}} -
issm/trunk-jpl/src/m/classes/frictionjosh.py
r25385 r25688 1 import numpy as np 2 1 3 from checkfield import checkfield 2 4 from fielddisplay import fielddisplay … … 6 8 7 9 class frictionjosh(object): 8 ''' 9 FRICTION class definition 10 """FRICTIONJOSH class definition 10 11 11 12 13 '''12 Usage: 13 frictionjosh = frictionjosh() 14 """ 14 15 15 16 def __init__(self): # {{{ 16 self.coefficient = float('NaN')17 self.pressure_adjusted_temperature = float('NaN')17 self.coefficient = np.nan 18 self.pressure_adjusted_temperature = np.nan 18 19 self.gamma = 0 19 20 self.effective_pressure_limit = 0 20 #set defaults 21 21 22 self.setdefaultparameters() 22 23 #self.requested_outputs = [] … … 24 25 25 26 def __repr__(self): # {{{ 26 s tring = "Basal shear stress parameters: Sigma_b = coefficient^2 * Neff ^r * |u_b|^(s - 1) * u_b, \n(effective stress Neff = rho_ice * g * thickness + rho_water * g * base, r = q / p and s = 1 / p)"27 28 s tring = "%s\n%s" % (string,fielddisplay(self, "coefficient", "friction coefficient [SI]"))29 s tring = "%s\n%s" % (string,fielddisplay(self, 'pressure_adjusted_temperature', 'friction pressure_adjusted_temperature (T - Tpmp) [K]'))30 s tring = "%s\n%s" % (string,fielddisplay(self, 'gamma', '(T - Tpmp)/gamma [K]'))31 s tring = "%s\n%s" % (string,fielddisplay(self, 'effective_pressure_limit', 'Neff do not allow to fall below a certain limit: effective_pressure_limit * rho_ice * g * thickness (default 0)'))32 #s tring = "%s\n%s" % (string,fielddisplay(self, 'requested_outputs', 'additional outputs requested'))33 return s tring27 s = 'Basal shear stress parameters: Sigma_b = coefficient^2 * Neff ^r * |u_b|^(s - 1) * u_b,\n' 28 s += '(effective stress Neff = rho_ice * g * thickness + rho_water * g * base, r = q / p and s = 1 / p)\n' 29 s += '{}\n'.format(fielddisplay(self, "coefficient", "friction coefficient [SI]")) 30 s += '{}\n'.format(fielddisplay(self, 'pressure_adjusted_temperature', 'friction pressure_adjusted_temperature (T - Tpmp) [K]')) 31 s += '{}\n'.format(fielddisplay(self, 'gamma', '(T - Tpmp)/gamma [K]')) 32 s += '{}\n'.format(fielddisplay(self, 'effective_pressure_limit', 'Neff do not allow to fall below a certain limit: effective_pressure_limit * rho_ice * g * thickness (default 0)')) 33 #s += '{}\n'.format(fielddisplay(self, 'requested_outputs', 'additional outputs requested')) 34 return s 34 35 #}}} 35 36 … … 53 54 54 55 def checkconsistency(self, md, solution, analyses): # {{{ 55 # Early return56 # Early return 56 57 if 'StressbalanceAnalysis' not in analyses and 'ThermalAnalysis' not in analyses: 57 58 return md 58 59 59 md = checkfield(md, 'fieldname', 'friction.coefficient', 'timeseries', 1, 'NaN', 1, 'Inf', 1) 60 60 md = checkfield(md, 'fieldname', 'friction.pressure_adjusted_temperature','NaN',1,'Inf',1) 61 61 md = checkfield(md, 'fieldname', 'friction.gamma','numel',1,'NaN',1,'Inf',1,'>',0.) 62 62 md = checkfield(md, 'fieldname', 'friction.effective_pressure_limit', 'numel', [1], '>=', 0) 63 64 #Check that temperature is provided 63 # Check that temperature is provided 65 64 md = checkfield(md,'fieldname','initialization.temperature','NaN',1,'Inf',1,'size','universal') 66 65 return md … … 73 72 WriteData(fid,prefix,'class','friction','object',self,'fieldname','gamma','format','Double') 74 73 WriteData(fid,prefix,'object',self,'class','friction','fieldname','effective_pressure_limit','format','Double') 75 76 74 # }}} -
issm/trunk-jpl/src/m/classes/frictionpism.py
r25023 r25688 1 1 import numpy as np 2 3 from checkfield import checkfield 2 4 from fielddisplay import fielddisplay 3 5 from project3d import project3d 4 from checkfield import checkfield5 6 from WriteData import WriteData 6 7 7 8 8 9 class frictionpism(object): 9 """ 10 frictionpism class definition 10 """FRICTIONPISM class definition 11 11 12 12 Usage: 13 frictionpism = frictionpism()13 frictionpism = frictionpism() 14 14 """ 15 15 16 def __init__(self): 16 17 self.pseudoplasticity_exponent = 0. … … 29 30 self.sediment_compressibility_coefficient = project3d(md, 'vector', self.sediment_compressibility_coefficient, 'type', 'node', 'layer', 1) 30 31 return self 31 32 # }}} 32 33 33 34 def setdefaultparameters(self): # {{{ … … 40 41 41 42 def checkconsistency(self, md, solution, analyses): # {{{ 42 43 #Early return 43 # Early return 44 44 if 'StressbalanceAnalysis' not in analyses and 'ThermalAnalysis' not in analyses: 45 45 return md 46 if solution == 'TransientSolution' and md.transient.isstressbalance == 0 and md.transient.isthermal == 0:46 if solution == 'TransientSolution' and not md.transient.isstressbalance and not md.transient.isthermal: 47 47 return md 48 49 48 md = checkfield(md, 'fieldname', 'friction.pseudoplasticity_exponent', 'numel', [1], '>', 0, 'NaN', 1, 'Inf', 1) 50 49 md = checkfield(md, 'fieldname', 'friction.threshold_speed', 'numel', [1], '>', 0, 'NaN', 1, 'Inf', 1) … … 53 52 md = checkfield(md, 'fieldname', 'friction.till_friction_angle', 'NaN', 1, 'Inf', 1, '<', 360., '>', 0., 'size', [md.mesh.numberofvertices]) #User should give angle in degrees, Matlab calculates in rad 54 53 md = checkfield(md, 'fieldname', 'friction.sediment_compressibility_coefficient', 'NaN', 1, 'Inf', 1, '<', 1., '>', 0., 'size', [md.mesh.numberofvertices]) 54 return md 55 55 # }}} 56 56 57 57 def __repr__(self): # {{{ 58 s tring = 'Basal shear stress parameters for the PISM friction law (See Aschwanden et al. 2016 for more details)'59 s tring = "%s\n%s" % (string,fielddisplay(self, 'pseudoplasticity_exponent', 'pseudoplasticity exponent [dimensionless]'))60 s tring = "%s\n%s" % (string,fielddisplay(self, 'threshold_speed', 'threshold speed [m / yr]'))61 s tring = "%s\n%s" % (string,fielddisplay(self, 'delta', 'lower limit of the effective pressure, expressed as a fraction of overburden pressure [dimensionless]'))62 s tring = "%s\n%s" % (string,fielddisplay(self, 'void_ratio', 'void ratio at a reference effective pressure [dimensionless]'))63 s tring = "%s\n%s" % (string,fielddisplay(self, 'till_friction_angle', 'till friction angle [deg], recommended default: 30 deg'))64 s tring = "%s\n%s" % (string,fielddisplay(self, 'sediment_compressibility_coefficient', 'coefficient of compressibility of the sediment [dimensionless], recommended default: 0.12'))65 58 s = 'Basal shear stress parameters for the PISM friction law (See Aschwanden et al. 2016 for more details)\n' 59 s += "{}\n".format(fielddisplay(self, 'pseudoplasticity_exponent', 'pseudoplasticity exponent [dimensionless]')) 60 s += "{}\n".format(fielddisplay(self, 'threshold_speed', 'threshold speed [m / yr]')) 61 s += "{}\n".format(fielddisplay(self, 'delta', 'lower limit of the effective pressure, expressed as a fraction of overburden pressure [dimensionless]')) 62 s += "{}\n".format(fielddisplay(self, 'void_ratio', 'void ratio at a reference effective pressure [dimensionless]')) 63 s += "{}\n".format(fielddisplay(self, 'till_friction_angle', 'till friction angle [deg], recommended default: 30 deg')) 64 s += "{}\n".format(fielddisplay(self, 'sediment_compressibility_coefficient', 'coefficient of compressibility of the sediment [dimensionless], recommended default: 0.12')) 65 # }}} 66 66 67 67 def marshall(self, prefix, md, fid): # {{{ 68 68 yts = md.constants.yts 69 70 69 WriteData(fid, prefix, 'name', 'md.friction.law', 'data', 10, 'format', 'Integer') 71 70 WriteData(fid, prefix, 'class', 'friction', 'object', self, 'fieldname', 'pseudoplasticity_exponent', 'format', 'Double') … … 75 74 WriteData(fid, prefix, 'class', 'friction', 'object', self, 'fieldname', 'till_friction_angle', 'format', 'DoubleMat', 'mattype', 1) 76 75 WriteData(fid, prefix, 'class', 'friction', 'object', self, 'fieldname', 'sediment_compressibility_coefficient', 'format', 'DoubleMat', 'mattype', 1) 77 76 # }}} -
issm/trunk-jpl/src/m/classes/frictionshakti.py
r25502 r25688 26 26 27 27 def __repr__(self): # {{{ 28 s = "Basal shear stress parameters: Sigma_b = coefficient^2 * Neff * u_b\n(effective stress Neff = rho_ice * g * thickness + rho_water * g * (head - b))\n" 28 s = 'Basal shear stress parameters: Sigma_b = coefficient^2 * Neff * u_b\n' 29 s += '(effective stress Neff = rho_ice * g * thickness + rho_water * g * (head - b))\n' 29 30 s += "{}\n".format(fielddisplay(self, "coefficient", "friction coefficient [SI]")) 30 31 31 return s 32 32 #}}} … … 45 45 if 'StressbalanceAnalysis' not in analyses and 'ThermalAnalysis' not in analyses: 46 46 return md 47 48 47 md = checkfield(md, 'fieldname', 'friction.coefficient', 'timeseries', 1, 'NaN', 1, 'Inf', 1) 49 50 48 return md 51 49 # }}} -
issm/trunk-jpl/src/m/classes/frictionwaterlayer.py
r25503 r25688 36 36 s = "{}\n".format(fielddisplay(self, 'q', 'q exponent')) 37 37 s = "{}\n".format(fielddisplay(self, 'water_layer', 'water thickness at the base of the ice (m)')) 38 39 38 return s 40 39 #}}} … … 45 44 46 45 def checkconsistency(self, md, solution, analyses): #{{{ 47 # Early return48 if ('StressbalanceAnalysis' not in analyses) and ('ThermalAnalysis' not in analyses):46 # Early return 47 if 'StressbalanceAnalysis' not in analyses and 'ThermalAnalysis' not in analyses: 49 48 return 50 51 49 md = checkfield(md, 'fieldname', 'friction.coefficient', 'timeseries', 1, 'NaN', 1, 'Inf', 1) 52 50 md = checkfield(md, 'fieldname', 'friction.f', 'size', [1], 'NaN', 1, 'Inf', 1) … … 54 52 md = checkfield(md, 'fieldname', 'friction.p', 'NaN', 1, 'Inf', 1, 'size', [md.mesh.numberofelements]) 55 53 md = checkfield(md, 'fieldname', 'thermal.spctemperature', 'Inf', 1, 'timeseries', 1, '>=', 0.) 54 return md 56 55 # }}} 57 56 … … 61 60 self.q = project3d(md, 'vector', self.q, 'type', 'element') 62 61 self.water_layer = project3d(md, 'vector', self.water_layer, 'type', 'node', 'layer', 1) 63 64 62 return self 65 63 # }}} -
issm/trunk-jpl/src/m/classes/geometry.py
r25169 r25688 8 8 9 9 class geometry(object): 10 ''' 11 GEOMETRY class definition 10 """GEOMETRY class definition 12 11 13 14 15 '''12 Usage: 13 geometry = geometry() 14 """ 16 15 17 def __init__(self ): #{{{16 def __init__(self, *args): #{{{ 18 17 self.surface = np.nan 19 18 self.thickness = np.nan … … 22 21 self.hydrostatic_ratio = np.nan 23 22 24 #set defaults 25 self.setdefaultparameters() 23 nargs = len(args) 24 if nargs == 0: 25 self.setdefaultparameters() 26 else: 27 raise Exception('constructor not supported') 26 28 #}}} 27 29 28 30 def __repr__(self): #{{{ 29 s = " geometry parameters:" 30 s = "%s\n%s" % (s, fielddisplay(self, 'surface', 'ice upper surface elevation [m]')) 31 s = "%s\n%s" % (s, fielddisplay(self, 'thickness', 'ice thickness [m]')) 32 s = "%s\n%s" % (s, fielddisplay(self, 'base', 'ice base elevation [m]')) 33 s = "%s\n%s" % (s, fielddisplay(self, 'bed', 'bed elevation [m]')) 34 31 s = ' geometry parameters:\n' 32 s += '{}\n'.format(fielddisplay(self, 'surface', 'ice upper surface elevation [m]')) 33 s += '{}\n'.format(fielddisplay(self, 'thickness', 'ice thickness [m]')) 34 s += '{}\n'.format(fielddisplay(self, 'base', 'ice base elevation [m]')) 35 s += '{}\n'.format(fielddisplay(self, 'bed', 'bed elevation [m]')) 35 36 return s 36 37 #}}} -
issm/trunk-jpl/src/m/classes/giaivins.m
r25129 r25688 35 35 if size(md.geometry.thickness,1)==md.mesh.numberofvertices+1, 36 36 %recover the furthest time "in time": 37 if( thickness(end,end)~=md.timestepping.start_time),37 if(md.geometry.thickness(end,end)~=md.timestepping.start_time), 38 38 md = checkmessage(md,['if ismasstransport is on, transient thickness forcing'... 39 39 ' for the giaivins model should not be provided in the future.'... … … 51 51 fielddisplay(self,'lithosphere_thickness','lithosphere thickness (km)'); 52 52 fielddisplay(self,'cross_section_shape','1: square-edged (default). 2: elliptical. See iedge in GiaDeflectionCore'); 53 53 True 54 54 end % }}} 55 55 function marshall(self,prefix,md,fid) % {{{ -
issm/trunk-jpl/src/m/classes/giaivins.py
r25158 r25688 8 8 9 9 class giaivins(object): 10 """ 11 GIA class definition for Ivins and James model 10 """GIA class definition for Ivins and James model 12 11 13 14 12 Usage: 13 giaivins = giaivins() 15 14 """ 16 15 … … 21 20 22 21 nargin = len(args) 23 24 22 if nargin == 0: 25 23 self.setdefaultparameters() … … 30 28 def __repr__(self): #{{{ 31 29 s = ' giaivins parameters:\n' 32 s += "{}\n".format(fielddisplay(self, 'mantle_viscosity', 'mantle viscosity [Pa s]')) 33 s += "{}\n".format(fielddisplay(self, 'lithosphere_thickness', 'lithosphere thickness (km)')) 34 s += "{}\n".format(fielddisplay(self, 'cross_section_shape', "1: square-edged (default). 2: elliptical. See iedge in GiaDeflectionCore")) 35 30 s += '{}\n'.format(fielddisplay(self, 'mantle_viscosity', 'mantle viscosity [Pa s]')) 31 s += '{}\n'.format(fielddisplay(self, 'lithosphere_thickness', 'lithosphere thickness (km)')) 32 s += '{}\n'.format(fielddisplay(self, 'cross_section_shape', "1: square-edged (default). 2: elliptical. See iedge in GiaDeflectionCore")) 36 33 return s 37 34 #}}} … … 39 36 def setdefaultparameters(self): #{{{ 40 37 self.cross_section_shape = 1 38 return self 41 39 #}}} 42 40 … … 49 47 md = checkfield(md, 'fieldname', 'gia.cross_section_shape', 'numel', [1], 'values', [1, 2]) 50 48 51 #be sure that if we are running a masstransport ice flow model coupled with giaivins, that thickness forcings 52 #are not provided into the future. 53 49 # Be sure that if we are running a masstransport ice flow model coupled 50 # with giaivins, that thickness forcings are not provided into the 51 # future. 52 if solution == 'TransientSolution' and md.transient.ismasstransport and md.transient.isgia: 53 # Figure out if thickness is a transient forcing 54 if md.geometry.thickness.shape[0] == md.mesh.numberofvertices + 1: 55 # Recover the furthest time "in time" 56 if md.geometry.thickness[-1, -1] != md.timestepping.start_time: 57 md.checkmessage('if masstransport is on, transient thickness forcing for the giaivins model should not be provided in the future. Synchronize your start_time to correspond to the most recent transient thickness forcing timestep') 54 58 return md 55 59 #}}} -
issm/trunk-jpl/src/m/classes/giamme.py
r25169 r25688 8 8 9 9 class giamme(object): 10 ''' 11 GIAMME class definition 10 """GIAMME class definition 12 11 13 14 15 '''12 Usage: 13 gia = giamme() #gia class based on a multi-model ensemble (ex: Caron et al 2017 statistics) 14 """ 16 15 17 16 def __init__(self, *args): #{{{ … … 33 32 s += '{}\n'.format(fielddisplay(self, 'Ngia', 'geoid (mm/yr).')) 34 33 s += '{}\n'.format(fielddisplay(self, 'Ugia', 'uplift (mm/yr).')) 35 36 34 return s 37 35 #}}} 38 36 39 37 def setdefaultparameters(self): # {{{ 40 return 38 return self 41 39 #}}} 42 40 43 41 def checkconsistency(self, md, solution, analyses): # {{{ 44 if ('SealevelriseAnalysis' not in analyses) or (solution == 'TransientSolution' and md.transient.isslr == 0):42 if 'SealevelriseAnalysis' not in analyses: 45 43 return md 46 44 if solution == 'TransientSolution' and not md.transient.isslr: 45 return md 47 46 md = checkfield(md, 'field', self.Ngia, 'NaN', 1, 'Inf', 1) 48 47 md = checkfield(md, 'field', self.Ugia, 'NaN', 1, 'Inf', 1) 49 48 md = checkfield(md, 'field', self.modelid, 'NaN', 1, 'Inf', 1, '>=', 0, '<=', len(self.Ngia)) 50 51 49 return md 52 50 #}}} … … 71 69 self.Ngia[i] = project3d(md, 'vector', self.Ngia[i], 'type', 'node', 'layer', 1) 72 70 self.Ugia[i] = project3d(md, 'vector', self.Ugia[i], 'type', 'node', 'layer', 1) 73 74 71 return self 75 72 #}}} -
issm/trunk-jpl/src/m/classes/initialization.py
r25385 r25688 1 1 import numpy as np 2 3 from checkfield import checkfield 4 from fielddisplay import fielddisplay 2 5 from project3d import project3d 3 from fielddisplay import fielddisplay4 from checkfield import checkfield5 6 from WriteData import WriteData 6 7 7 8 8 9 class initialization(object): 9 """ 10 INITIALIZATION class definition 10 """INITIALIZATION class definition 11 11 12 12 Usage: … … 15 15 16 16 def __init__(self): # {{{ 17 self.vx = np.nan 18 self.vy = np.nan 19 self.vz = np.nan 20 self.vel = np.nan 21 self.enthalpy = np.nan 22 self.pressure = np.nan 23 self.temperature = np.nan 24 self.waterfraction = np.nan 25 self.watercolumn = np.nan 26 self.sediment_head = np.nan 27 self.epl_head = np.nan 28 self.epl_thickness = np.nan 29 self.hydraulic_potential = np.nan 30 self.channelarea = np.nan 17 31 18 self.vx = float('NaN') 19 self.vy = float('NaN') 20 self.vz = float('NaN') 21 self.vel = float('NaN') 22 self.enthalpy = float('NaN') 23 self.pressure = float('NaN') 24 self.temperature = float('NaN') 25 self.waterfraction = float('NaN') 26 self.watercolumn = float('NaN') 27 self.sediment_head = float('NaN') 28 self.epl_head = float('NaN') 29 self.epl_thickness = float('NaN') 30 self.hydraulic_potential = float('NaN') 31 self.channelarea = float('NaN') 32 33 #set defaults 32 #set defaults 34 33 self.setdefaultparameters() 35 36 34 #}}} 37 35 38 36 def __repr__(self): # {{{ 39 string = ' initial field values:' 40 string = "%s\n%s" % (string, fielddisplay(self, 'vx', 'x component of velocity [m / yr]')) 41 string = "%s\n%s" % (string, fielddisplay(self, 'vy', 'y component of velocity [m / yr]')) 42 string = "%s\n%s" % (string, fielddisplay(self, 'vz', 'z component of velocity [m / yr]')) 43 string = "%s\n%s" % (string, fielddisplay(self, 'vel', 'velocity norm [m / yr]')) 44 string = "%s\n%s" % (string, fielddisplay(self, 'pressure', 'pressure [Pa]')) 45 string = "%s\n%s" % (string, fielddisplay(self, 'temperature', 'temperature [K]')) 46 string = "%s\n%s" % (string, fielddisplay(self, 'enthalpy', 'enthalpy [J]')) 47 string = "%s\n%s" % (string, fielddisplay(self, 'waterfraction', 'fraction of water in the ice')) 48 string = "%s\n%s" % (string, fielddisplay(self, 'watercolumn', 'thickness of subglacial water [m]')) 49 string = "%s\n%s" % (string, fielddisplay(self, 'sediment_head', 'sediment water head of subglacial system [m]')) 50 string = "%s\n%s" % (string, fielddisplay(self, 'epl_head', 'epl water head of subglacial system [m]')) 51 string = "%s\n%s" % (string, fielddisplay(self, 'epl_thickness', 'thickness of the epl [m]')) 52 string = "%s\n%s" % (string, fielddisplay(self, 'hydraulic_potential', 'Hydraulic potential (for GlaDS) [Pa]')) 53 string = "%s\n%s" % (string, fielddisplay(self, 'channelarea', 'subglaciale water channel area (for GlaDS) [m2]')) 54 55 return string 37 s = ' initial field values:\n' 38 s += '{}\n'.format(fielddisplay(self, 'vx', 'x component of velocity [m / yr]')) 39 s += '{}\n'.format(fielddisplay(self, 'vy', 'y component of velocity [m / yr]')) 40 s += '{}\n'.format(fielddisplay(self, 'vz', 'z component of velocity [m / yr]')) 41 s += '{}\n'.format(fielddisplay(self, 'vel', 'velocity norm [m / yr]')) 42 s += '{}\n'.format(fielddisplay(self, 'pressure', 'pressure [Pa]')) 43 s += '{}\n'.format(fielddisplay(self, 'temperature', 'temperature [K]')) 44 s += '{}\n'.format(fielddisplay(self, 'enthalpy', 'enthalpy [J]')) 45 s += '{}\n'.format(fielddisplay(self, 'waterfraction', 'fraction of water in the ice')) 46 s += '{}\n'.format(fielddisplay(self, 'watercolumn', 'thickness of subglacial water [m]')) 47 s += '{}\n'.format(fielddisplay(self, 'sediment_head', 'sediment water head of subglacial system [m]')) 48 s += '{}\n'.format(fielddisplay(self, 'epl_head', 'epl water head of subglacial system [m]')) 49 s += '{}\n'.format(fielddisplay(self, 'epl_thickness', 'thickness of the epl [m]')) 50 s += '{}\n'.format(fielddisplay(self, 'hydraulic_potential', 'Hydraulic potential (for GlaDS) [Pa]')) 51 s += '{}\n'.format(fielddisplay(self, 'channelarea', 'subglaciale water channel area (for GlaDS) [m2]')) 52 return s 56 53 #}}} 57 54 … … 70 67 71 68 #Lithostatic pressure by default 72 # self.pressure = md.constants.g * md.materials.rho_ice * (md.geometry.surface[:, 0] - md.mesh.z)73 #self.pressure = md.constants.g * md.materials.rho_ice * (md.geometry.surface-md.mesh.z.reshape(-1, ))74 75 69 if np.ndim(md.geometry.surface) == 2: 76 print('Reshaping md.geometry.surface for you convenience but you should fix it in you files')70 print('Reshaping md.geometry.surface for your convenience but you should fix it in your model set up') 77 71 self.pressure = md.constants.g * md.materials.rho_ice * (md.geometry.surface.reshape(-1, ) - md.mesh.z) 78 72 else: … … 87 81 88 82 def checkconsistency(self, md, solution, analyses): # {{{ 89 if 'StressbalanceAnalysis' in analyses :83 if 'StressbalanceAnalysis' in analyses and not solution == 'TransientSolution' and not md.transient.isstressbalance: 90 84 if not np.any(np.logical_or(np.isnan(md.initialization.vx), np.isnan(md.initialization.vy))): 91 85 md = checkfield(md, 'fieldname', 'initialization.vx', 'NaN', 1, 'Inf', 1, 'size', [md.mesh.numberofvertices]) 92 86 md = checkfield(md, 'fieldname', 'initialization.vy', 'NaN', 1, 'Inf', 1, 'size', [md.mesh.numberofvertices]) 93 if 'MasstransportAnalysis' in analyses :87 if 'MasstransportAnalysis' in analyses and not solution == 'TransientSolution' and not md.transient.ismasstransport: 94 88 md = checkfield(md, 'fieldname', 'initialization.vx', 'NaN', 1, 'Inf', 1, 'size', [md.mesh.numberofvertices]) 95 89 md = checkfield(md, 'fieldname', 'initialization.vy', 'NaN', 1, 'Inf', 1, 'size', [md.mesh.numberofvertices]) 96 if 'BalancethicknessAnalysis' in analyses :90 if 'BalancethicknessAnalysis' in analyses and solution == 'BalancethicknessSolution': 97 91 md = checkfield(md, 'fieldname', 'initialization.vx', 'NaN', 1, 'Inf', 1, 'size', [md.mesh.numberofvertices]) 98 92 md = checkfield(md, 'fieldname', 'initialization.vy', 'NaN', 1, 'Inf', 1, 'size', [md.mesh.numberofvertices]) 99 # Triangle with zero velocity93 # Triangle with zero velocity 100 94 if np.any(np.logical_and(np.sum(np.abs(md.initialization.vx[md.mesh.elements - 1]), axis=1) == 0, 101 95 np.sum(np.abs(md.initialization.vy[md.mesh.elements - 1]), axis=1) == 0)): 102 96 md.checkmessage("at least one triangle has all its vertices with a zero velocity") 103 if 'ThermalAnalysis' in analyses and not (solution == 'TransientSolution' and md.transient.isthermal == 0):97 if 'ThermalAnalysis' in analyses and not solution == 'TransientSolution' and not md.transient.isthermal: 104 98 md = checkfield(md, 'fieldname', 'initialization.vx', 'NaN', 1, 'Inf', 1, 'size', [md.mesh.numberofvertices]) 105 99 md = checkfield(md, 'fieldname', 'initialization.vy', 'NaN', 1, 'Inf', 1, 'size', [md.mesh.numberofvertices]) … … 108 102 md = checkfield(md, 'fieldname', 'initialization.vz', 'NaN', 1, 'Inf', 1, 'size', [md.mesh.numberofvertices]) 109 103 md = checkfield(md, 'fieldname', 'initialization.pressure', 'NaN', 1, 'Inf', 1, 'size', [md.mesh.numberofvertices]) 110 if ('EnthalpyAnalysis' in analyses and md.thermal.isenthalpy):111 112 113 114 115 104 if 'EnthalpyAnalysis' in analyses and md.thermal.isenthalpy: 105 md = checkfield(md, 'fieldname', 'initialization.waterfraction', '>=', 0, 'size', [md.mesh.numberofvertices]) 106 md = checkfield(md, 'fieldname', 'initialization.watercolumn', '>=', 0, 'size', [md.mesh.numberofvertices]) 107 pos = np.nonzero(md.initialization.waterfraction > 0.)[0] 108 if(pos.size): 109 md = checkfield(md, 'fieldname', 'delta Tpmp', 'field', np.absolute(md.initialization.temperature[pos] - (md.materials.meltingpoint - md.materials.beta * md.initialization.pressure[pos])), '<', 1e-11, 'message', 'set temperature to pressure melting point at locations with waterfraction > 0') 116 110 if 'HydrologyShreveAnalysis' in analyses: 117 111 if hasattr(md.hydrology, 'hydrologyshreve'): … … 134 128 135 129 def marshall(self, prefix, md, fid): # {{{ 136 137 130 yts = md.constants.yts 138 139 131 WriteData(fid, prefix, 'object', self, 'fieldname', 'vx', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1. / yts) 140 132 WriteData(fid, prefix, 'object', self, 'fieldname', 'vy', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1. / yts) -
issm/trunk-jpl/src/m/classes/inversion.m
r22303 r25688 108 108 end 109 109 end 110 111 110 if strcmp(solution,'BalancethicknessSolution') 112 111 md = checkfield(md,'fieldname','inversion.thickness_obs','size',[md.mesh.numberofvertices 1],'NaN',1,'Inf',1); -
issm/trunk-jpl/src/m/classes/inversion.py
r24261 r25688 1 1 import numpy as np 2 3 from checkfield import checkfield 4 from fielddisplay import fielddisplay 5 from marshallcostfunctions import marshallcostfunctions 2 6 from project3d import project3d 3 from fielddisplay import fielddisplay4 from checkfield import checkfield5 from WriteData import WriteData6 7 from supportedcontrols import supportedcontrols 7 8 from supportedcostfunctions import supportedcostfunctions 8 from marshallcostfunctions import marshallcostfunctions9 from WriteData import WriteData 9 10 10 11 11 12 class inversion(object): 12 """ 13 INVERSION class definition 13 """INVERSION class definition 14 14 15 16 15 Usage: 16 inversion = inversion() 17 17 """ 18 18 … … 20 20 self.iscontrol = 0 21 21 self.incomplete_adjoint = 0 22 self.control_parameters = float('NaN')22 self.control_parameters = np.nan 23 23 self.nsteps = 0 24 self.maxiter_per_step = float('NaN')24 self.maxiter_per_step = np.nan 25 25 self.cost_functions = '' 26 self.cost_functions_coefficients = float('NaN')27 self.gradient_scaling = float('NaN')26 self.cost_functions_coefficients = np.nan 27 self.gradient_scaling = np.nan 28 28 self.cost_function_threshold = 0 29 self.min_parameters = float('NaN')30 self.max_parameters = float('NaN')31 self.step_threshold = float('NaN')32 self.vx_obs = float('NaN')33 self.vy_obs = float('NaN')34 self.vz_obs = float('NaN')35 self.vel_obs = float('NaN')36 self.thickness_obs = float('NaN')37 self.surface_obs = float('NaN')29 self.min_parameters = np.nan 30 self.max_parameters = np.nan 31 self.step_threshold = np.nan 32 self.vx_obs = np.nan 33 self.vy_obs = np.nan 34 self.vz_obs = np.nan 35 self.vel_obs = np.nan 36 self.thickness_obs = np.nan 37 self.surface_obs = np.nan 38 38 39 #set defaults40 39 self.setdefaultparameters() 41 42 40 #}}} 43 41 44 42 def __repr__(self): # {{{ 45 string = ' inversion parameters:' 46 string = "%s\n%s" % (string, fielddisplay(self, 'iscontrol', 'is inversion activated?')) 47 string = "%s\n%s" % (string, fielddisplay(self, 'incomplete_adjoint', '1: linear viscosity, 0: non - linear viscosity')) 48 string = "%s\n%s" % (string, fielddisplay(self, 'control_parameters', 'ex: {''FrictionCoefficient''}, or {''MaterialsRheologyBbar''}')) 49 string = "%s\n%s" % (string, fielddisplay(self, 'nsteps', 'number of optimization searches')) 50 string = "%s\n%s" % (string, fielddisplay(self, 'cost_functions', 'indicate the type of response for each optimization step')) 51 string = "%s\n%s" % (string, fielddisplay(self, 'cost_functions_coefficients', 'cost_functions_coefficients applied to the misfit of each vertex and for each control_parameter')) 52 string = "%s\n%s" % (string, fielddisplay(self, 'cost_function_threshold', 'misfit convergence criterion. Default is 1%, NaN if not applied')) 53 string = "%s\n%s" % (string, fielddisplay(self, 'maxiter_per_step', 'maximum iterations during each optimization step')) 54 string = "%s\n%s" % (string, fielddisplay(self, 'gradient_scaling', 'scaling factor on gradient direction during optimization, for each optimization step')) 55 string = "%s\n%s" % (string, fielddisplay(self, 'step_threshold', 'decrease threshold for misfit, default is 30%')) 56 string = "%s\n%s" % (string, fielddisplay(self, 'min_parameters', 'absolute minimum acceptable value of the inversed parameter on each vertex')) 57 string = "%s\n%s" % (string, fielddisplay(self, 'max_parameters', 'absolute maximum acceptable value of the inversed parameter on each vertex')) 58 string = "%s\n%s" % (string, fielddisplay(self, 'vx_obs', 'observed velocity x component [m / yr]')) 59 string = "%s\n%s" % (string, fielddisplay(self, 'vy_obs', 'observed velocity y component [m / yr]')) 60 string = "%s\n%s" % (string, fielddisplay(self, 'vel_obs', 'observed velocity magnitude [m / yr]')) 61 string = "%s\n%s" % (string, fielddisplay(self, 'thickness_obs', 'observed thickness [m]')) 62 string = "%s\n%s" % (string, fielddisplay(self, 'surface_obs', 'observed surface elevation [m]')) 63 string = "%s\n%s" % (string, 'Available cost functions:') 64 string = "%s\n%s" % (string, ' 101: SurfaceAbsVelMisfit') 65 string = "%s\n%s" % (string, ' 102: SurfaceRelVelMisfit') 66 string = "%s\n%s" % (string, ' 103: SurfaceLogVelMisfit') 67 string = "%s\n%s" % (string, ' 104: SurfaceLogVxVyMisfit') 68 string = "%s\n%s" % (string, ' 105: SurfaceAverageVelMisfit') 69 string = "%s\n%s" % (string, ' 201: ThicknessAbsMisfit') 70 string = "%s\n%s" % (string, ' 501: DragCoefficientAbsGradient') 71 string = "%s\n%s" % (string, ' 502: RheologyBbarAbsGradient') 72 string = "%s\n%s" % (string, ' 503: ThicknessAbsGradient') 73 return string 74 #}}} 75 76 def extrude(self, md): # {{{ 77 self.vx_obs = project3d(md, 'vector', self.vx_obs, 'type', 'node') 78 self.vy_obs = project3d(md, 'vector', self.vy_obs, 'type', 'node') 79 self.vel_obs = project3d(md, 'vector', self.vel_obs, 'type', 'node') 80 self.thickness_obs = project3d(md, 'vector', self.thickness_obs, 'type', 'node') 81 if not np.any(np.isnan(self.cost_functions_coefficients)): 82 self.cost_functions_coefficients = project3d(md, 'vector', self.cost_functions_coefficients, 'type', 'node') 83 if not np.any(np.isnan(self.min_parameters)): 84 self.min_parameters = project3d(md, 'vector', self.min_parameters, 'type', 'node') 85 if not np.any(np.isnan(self.max_parameters)): 86 self.max_parameters = project3d(md, 'vector', self.max_parameters, 'type', 'node') 87 return self 43 s = ' inversion parameters:\n' 44 s += '{}\n'.format(fielddisplay(self, 'iscontrol', 'is inversion activated?')) 45 s += '{}\n'.format(fielddisplay(self, 'incomplete_adjoint', '1: linear viscosity, 0: non - linear viscosity')) 46 s += '{}\n'.format(fielddisplay(self, 'control_parameters', 'ex: {''FrictionCoefficient''}, or {''MaterialsRheologyBbar''}')) 47 s += '{}\n'.format(fielddisplay(self, 'nsteps', 'number of optimization searches')) 48 s += '{}\n'.format(fielddisplay(self, 'cost_functions', 'indicate the type of response for each optimization step')) 49 s += '{}\n'.format(fielddisplay(self, 'cost_functions_coefficients', 'cost_functions_coefficients applied to the misfit of each vertex and for each control_parameter')) 50 s += '{}\n'.format(fielddisplay(self, 'cost_function_threshold', 'misfit convergence criterion. Default is 1%, NaN if not applied')) 51 s += '{}\n'.format(fielddisplay(self, 'maxiter_per_step', 'maximum iterations during each optimization step')) 52 s += '{}\n'.format(fielddisplay(self, 'gradient_scaling', 'scaling factor on gradient direction during optimization, for each optimization step')) 53 s += '{}\n'.format(fielddisplay(self, 'step_threshold', 'decrease threshold for misfit, default is 30%')) 54 s += '{}\n'.format(fielddisplay(self, 'min_parameters', 'absolute minimum acceptable value of the inversed parameter on each vertex')) 55 s += '{}\n'.format(fielddisplay(self, 'max_parameters', 'absolute maximum acceptable value of the inversed parameter on each vertex')) 56 s += '{}\n'.format(fielddisplay(self, 'vx_obs', 'observed velocity x component [m / yr]')) 57 s += '{}\n'.format(fielddisplay(self, 'vy_obs', 'observed velocity y component [m / yr]')) 58 s += '{}\n'.format(fielddisplay(self, 'vel_obs', 'observed velocity magnitude [m / yr]')) 59 s += '{}\n'.format(fielddisplay(self, 'thickness_obs', 'observed thickness [m]')) 60 s += '{}\n'.format(fielddisplay(self, 'surface_obs', 'observed surface elevation [m]')) 61 s += '{}\n'.format('Available cost functions:') 62 s += '{}\n'.format(' 101: SurfaceAbsVelMisfit') 63 s += '{}\n'.format(' 102: SurfaceRelVelMisfit') 64 s += '{}\n'.format(' 103: SurfaceLogVelMisfit') 65 s += '{}\n'.format(' 104: SurfaceLogVxVyMisfit') 66 s += '{}\n'.format(' 105: SurfaceAverageVelMisfit') 67 s += '{}\n'.format(' 201: ThicknessAbsMisfit') 68 s += '{}\n'.format(' 501: DragCoefficientAbsGradient') 69 s += '{}\n'.format(' 502: RheologyBbarAbsGradient') 70 s += '{}\n'.format(' 503: ThicknessAbsGradient') 71 return s 88 72 #}}} 89 73 90 74 def setdefaultparameters(self): # {{{ 91 92 75 #default is incomplete adjoint for now 93 76 self.incomplete_adjoint = 1 … … 115 98 #if J[n] - J[n - 1] / J[n] < criteria, the control run stops 116 99 #NaN if not applied 117 self.cost_function_threshold = float('NaN') #not activated 100 self.cost_function_threshold = np.nan #not activated 101 return self 102 #}}} 118 103 104 def extrude(self, md): # {{{ 105 self.vx_obs = project3d(md, 'vector', self.vx_obs, 'type', 'node') 106 self.vy_obs = project3d(md, 'vector', self.vy_obs, 'type', 'node') 107 self.vel_obs = project3d(md, 'vector', self.vel_obs, 'type', 'node') 108 self.thickness_obs = project3d(md, 'vector', self.thickness_obs, 'type', 'node') 109 if not np.any(np.isnan(self.cost_functions_coefficients)): 110 self.cost_functions_coefficients = project3d(md, 'vector', self.cost_functions_coefficients, 'type', 'node') 111 if not np.any(np.isnan(self.min_parameters)): 112 self.min_parameters = project3d(md, 'vector', self.min_parameters, 'type', 'node') 113 if not np.any(np.isnan(self.max_parameters)): 114 self.max_parameters = project3d(md, 'vector', self.max_parameters, 'type', 'node') 119 115 return self 120 116 #}}} 121 117 122 118 def checkconsistency(self, md, solution, analyses): # {{{ 123 # Early return119 # Early return 124 120 if not self.iscontrol: 125 121 return md … … 140 136 md = checkfield(md, 'fieldname', 'inversion.max_parameters', 'size', [md.mesh.numberofvertices, num_controls]) 141 137 142 #Only SSA, HO and FS are supported right now138 # Only SSA, HO and FS are supported right now 143 139 if solution == 'StressbalanceSolution': 144 140 if not (md.flowequation.isSSA or md.flowequation.isHO or md.flowequation.isFS or md.flowequation.isL1L2): 145 141 md.checkmessage("'inversion can only be performed for SSA, HO or FS ice flow models") 146 147 142 if solution == 'BalancethicknessSolution': 143 md = checkfield(md, 'fieldname', 'inversion.thickness_obs', 'size', [md.mesh.numberofvertices], 'NaN', 1, 'Inf', 1) 144 elif solution == 'BalancethicknessSoftSolution': 148 145 md = checkfield(md, 'fieldname', 'inversion.thickness_obs', 'size', [md.mesh.numberofvertices], 'NaN', 1, 'Inf', 1) 149 146 else: 150 147 md = checkfield(md, 'fieldname', 'inversion.vx_obs', 'size', [md.mesh.numberofvertices], 'NaN', 1, 'Inf', 1) 151 148 md = checkfield(md, 'fieldname', 'inversion.vy_obs', 'size', [md.mesh.numberofvertices], 'NaN', 1, 'Inf', 1) 152 153 149 return md 154 150 # }}} … … 177 173 WriteData(fid, prefix, 'object', self, 'fieldname', 'surface_obs', 'format', 'DoubleMat', 'mattype', 1) 178 174 179 #process control parameters175 # Process control parameters 180 176 num_control_parameters = len(self.control_parameters) 181 177 WriteData(fid, prefix, 'object', self, 'fieldname', 'control_parameters', 'format', 'StringArray') 182 178 WriteData(fid, prefix, 'data', num_control_parameters, 'name', 'md.inversion.num_control_parameters', 'format', 'Integer') 183 179 184 #process cost functions180 # Process cost functions 185 181 num_cost_functions = np.size(self.cost_functions) 186 182 data = marshallcostfunctions(self.cost_functions) -
issm/trunk-jpl/src/m/classes/linearbasalforcings.py
r25158 r25688 3 3 from checkfield import checkfield 4 4 from fielddisplay import fielddisplay 5 from project3d import project3d 5 6 from WriteData import WriteData 6 7 7 8 8 9 class linearbasalforcings(object): 9 """ 10 LINEAR BASAL FORCINGS class definition 10 """LINEAR BASAL FORCINGS class definition 11 11 12 13 12 Usage: 13 basalforcings = linearbasalforcings() 14 14 """ 15 15 16 def __init__(self, *args): #{{{17 18 if n ot len(args):16 def __init__(self, *args): #{{{ 17 nargs = len(args) 18 if nargs == 0: 19 19 print('empty init') 20 20 self.deepwater_melting_rate = 0. … … 26 26 self.geothermalflux = float('NaN') 27 27 28 #set defaults28 # set defaults 29 29 self.setdefaultparameters() 30 elif len(args)== 1 and args[0].__module__ == 'basalforcings':30 elif nargs == 1 and args[0].__module__ == 'basalforcings': 31 31 print('converting basalforings to linearbasalforcings') 32 32 inv = args[0] … … 39 39 self.upperwater_elevation = 0. 40 40 41 #set defaults41 # Set defaults 42 42 self.setdefaultparameters() 43 43 else: 44 44 raise Exception('constructor not supported') 45 45 #}}} 46 def __repr__(self): # {{{ 47 string = " linear basal forcings parameters:" 48 string = "%s\n%s" % (string, fielddisplay(self, "deepwater_melting_rate", "basal melting rate (positive if melting applied for floating ice whith base < deepwater_elevation) [m/yr]")) 49 string = "%s\n%s" % (string, fielddisplay(self, "deepwater_elevation", "elevation of ocean deepwater [m]")) 50 string = "%s\n%s" % (string, fielddisplay(self, "upperwater_melting_rate", "upper melting rate (positive if melting applied for floating ice whith base >= upperwater_elevation) [m/yr]")) 51 string = "%s\n%s" % (string, fielddisplay(self, "upperwater_elevation", "elevation of ocean upper water [m]")) 52 string = "%s\n%s" % (string, fielddisplay(self, "groundedice_melting_rate", "basal melting rate (positive if melting) [m/yr]")) 53 string = "%s\n%s" % (string, fielddisplay(self, "perturbation_melting_rate", "perturbation applied to computed melting rate (positive if melting) [m/yr]")) 54 string = "%s\n%s" % (string, fielddisplay(self, "geothermalflux", "geothermal heat flux [W/m^2]")) 55 return string 46 47 def __repr__(self): #{{{ 48 s = ' linear basal forcings parameters:\n' 49 s += '{}\n'.format(fielddisplay(self, "deepwater_melting_rate", "basal melting rate (positive if melting applied for floating ice whith base < deepwater_elevation) [m/yr]")) 50 s += '{}\n'.format(fielddisplay(self, "deepwater_elevation", "elevation of ocean deepwater [m]")) 51 s += '{}\n'.format(fielddisplay(self, "upperwater_melting_rate", "upper melting rate (positive if melting applied for floating ice whith base >= upperwater_elevation) [m/yr]")) 52 s += '{}\n'.format(fielddisplay(self, "upperwater_elevation", "elevation of ocean upper water [m]")) 53 s += '{}\n'.format(fielddisplay(self, "groundedice_melting_rate", "basal melting rate (positive if melting) [m/yr]")) 54 s += '{}\n'.format(fielddisplay(self, "perturbation_melting_rate", "perturbation applied to computed melting rate (positive if melting) [m/yr]")) 55 s += '{}\n'.format(fielddisplay(self, "geothermalflux", "geothermal heat flux [W/m^2]")) 56 return s 56 57 #}}} 57 def initialize(self, md): # {{{ 58 59 def extrude(self, md): #{{{ 60 self.perturbation_melting_rate = project3d(md, 'vector', self.perturbation_melting_rate, 'type', 'node', 'layer', 1) 61 self.groundedice_melting_rate = project3d(md, 'vector', self.groundedice_melting_rate, 'type', 'node', 'layer', 1) 62 self.geothermalflux = project3d(md, 'vector', self.geothermalflux, 'type', 'node', 'layer', 1) # Bedrock only gets geothermal flux 63 return self 64 #}}} 65 66 def initialize(self, md): #{{{ 58 67 if np.all(np.isnan(self.groundedice_melting_rate)): 59 68 self.groundedice_melting_rate = np.zeros((md.mesh.numberofvertices)) … … 61 70 return self 62 71 #}}} 72 63 73 def setdefaultparameters(self): # {{{ 64 74 self.deepwater_melting_rate = 50.0 … … 66 76 self.upperwater_melting_rate = 0.0 67 77 self.upperwater_elevation = -400.0 78 return self 68 79 #}}} 69 def checkconsistency(self, md, solution, analyses): # {{{70 80 81 def checkconsistency(self, md, solution, analyses): #{{{ 71 82 if not np.all(np.isnan(self.perturbation_melting_rate)): 72 83 md = checkfield(md, 'fieldname', 'basalforcings.perturbation_melting_rate', 'NaN', 1, 'Inf', 1, 'timeseries', 1) 73 74 if 'MasstransportAnalysis' in analyses and not (solution == 'TransientSolution' and not md.transient.ismasstransport): 84 if 'MasstransportAnalysis' in analyses and not solution == 'TransientSolution' and not md.transient.ismasstransport: 75 85 md = checkfield(md, 'fieldname', 'basalforcings.groundedice_melting_rate', 'NaN', 1, 'Inf', 1, 'timeseries', 1) 76 86 md = checkfield(md, 'fieldname', 'basalforcings.deepwater_melting_rate', '>=', 0, 'singletimeseries', 1) … … 78 88 md = checkfield(md, 'fieldname', 'basalforcings.deepwater_elevation', '<', 'basalforcings.upperwater_elevation', 'singletimeseries', 1) 79 89 md = checkfield(md, 'fieldname', 'basalforcings.upperwater_elevation', '<=', 0, 'singletimeseries', 1) 80 81 90 if 'BalancethicknessAnalysis' in analyses: 82 91 md = checkfield(md, 'fieldname', 'basalforcings.groundedice_melting_rate', 'NaN', 1, 'Inf', 1, 'size', [md.mesh.numberofvertices]) … … 85 94 md = checkfield(md, 'fieldname', 'basalforcings.deepwater_elevation', '<', 'basalforcings.upperwater_elevation', 'singletimeseries', 1) 86 95 md = checkfield(md, 'fieldname', 'basalforcings.upperwater_elevation', '<=', 0, 'singletimeseries', 1) 87 88 if 'ThermalAnalysis' in analyses and not (solution == 'TransientSolution' and not md.transient.isthermal): 96 if 'ThermalAnalysis' in analyses and not solution == 'TransientSolution' and not md.transient.isthermal: 89 97 md = checkfield(md, 'fieldname', 'basalforcings.groundedice_melting_rate', 'NaN', 1, 'Inf', 1, 'timeseries', 1) 90 98 md = checkfield(md, 'fieldname', 'basalforcings.deepwater_melting_rate', '>=', 0, 'singletimeseries', 1) … … 95 103 96 104 return md 97 # }}} 98 def marshall(self, prefix, md, fid): # {{{ 105 #}}} 106 107 def marshall(self, prefix, md, fid): #{{{ 99 108 yts = md.constants.yts 100 109 … … 107 116 WriteData(fid, prefix, 'object', self, 'fieldname', 'upperwater_melting_rate', 'format', 'DoubleMat', 'mattype', 3, 'timeserieslength', 2, 'name', 'md.basalforcings.upperwater_melting_rate', 'scale', 1. / yts, 'yts', yts) 108 117 WriteData(fid, prefix, 'object', self, 'fieldname', 'upperwater_elevation', 'format', 'DoubleMat', 'mattype', 3, 'name', 'md.basalforcings.upperwater_elevation', 'yts', yts) 109 # 118 #}}} -
issm/trunk-jpl/src/m/classes/lovenumbers.py
r25183 r25688 9 9 10 10 class lovenumbers(object): #{{{ 11 ''' 12 LOVENUMBERS numbers class definition 11 """LOVENUMBERS class definition 13 12 14 15 16 17 '''13 Usage: 14 lovenumbers = lovenumbers() #will setup love numbers deg 1001 by default 15 lovenumbers = lovenumbers('maxdeg', 10001); #supply numbers of degrees required (here, 10001) 16 """ 18 17 19 18 def __init__(self, *args): #{{{ 20 # regular love numbers:21 self.h = [] # provided by PREM model22 self.k = [] # idem23 self.l = [] # idem19 # Regular love numbers 20 self.h = [] # Provided by PREM model 21 self.k = [] # idem 22 self.l = [] # idem 24 23 25 # tidal love numbers for computing rotational feedback:24 # Tidal love numbers for computing rotational feedback 26 25 self.th = [] 27 26 self.tk = [] 28 27 self.tl = [] 29 self.tk2secular = 0 # deg 2 secular number.28 self.tk2secular = 0 # deg 2 secular number 30 29 31 30 options = pairoptions(*args) … … 36 35 37 36 def setdefaultparameters(self, maxdeg, referenceframe): #{{{ 38 # initialize love numbers:37 # Initialize love numbers 39 38 self.h = getlovenumbers('type', 'loadingverticaldisplacement', 'referenceframe', referenceframe, 'maxdeg', maxdeg) 40 39 self.k = getlovenumbers('type', 'loadinggravitationalpotential', 'referenceframe', referenceframe, 'maxdeg', maxdeg) … … 44 43 self.tl = getlovenumbers('type', 'tidalhorizontaldisplacement', 'referenceframe', referenceframe, 'maxdeg', maxdeg) 45 44 46 # secular fluid love number:45 # Secular fluid love number 47 46 self.tk2secular = 0.942 47 return self 48 48 #}}} 49 49 50 50 def checkconsistency(self, md, solution, analyses): #{{{ 51 if ('SealevelriseAnalysis' not in analyses) or (solution == 'TransientSolution' and md.transient.isslr == 0):51 if ('SealevelriseAnalysis' not in analyses) or (solution == 'TransientSolution' and not md.transient.isslr): 52 52 return 53 54 53 md = checkfield(md, 'fieldname', 'solidearth.lovenumbers.h', 'NaN', 1, 'Inf', 1) 55 54 md = checkfield(md, 'fieldname', 'solidearth.lovenumbers.k', 'NaN', 1, 'Inf', 1) … … 59 58 md = checkfield(md, 'fieldname', 'solidearth.lovenumbers.tk', 'NaN', 1, 'Inf', 1) 60 59 md = checkfield(md, 'fieldname', 'solidearth.lovenumbers.tk2secular', 'NaN', 1, 'Inf', 1) 61 62 #check that love numbers are provided at the same level of accuracy: 60 # Check that love numbers are provided at the same level of accuracy 63 61 if (self.h.shape[0] != self.k.shape[0]) or (self.h.shape[0] != self.l.shape[0]): 64 62 raise ValueError('lovenumbers error message: love numbers should be provided at the same level of accuracy') 63 return md 65 64 #}}} 66 65 … … 70 69 71 70 def __repr__(self): #{{{ 72 s = ' lovenumbers parameters:' 73 71 s = ' lovenumbers parameters:\n' 74 72 s += '{}\n'.format(fielddisplay(self, 'h', 'load Love number for radial displacement')) 75 73 s += '{}\n'.format(fielddisplay(self, 'k', 'load Love number for gravitational potential perturbation')) … … 78 76 s += '{}\n'.format(fielddisplay(self, 'tk', 'tidal load Love number (deg 2)')) 79 77 s += '{}\n'.format(fielddisplay(self, 'tk2secular', 'secular fluid Love number')) 80 81 78 return s 82 79 #}}} -
issm/trunk-jpl/src/m/classes/m1qn3inversion.py
r24213 r25688 1 1 import numpy as np 2 3 from checkfield import checkfield 4 from fielddisplay import fielddisplay 5 from marshallcostfunctions import marshallcostfunctions 2 6 from project3d import project3d 3 from fielddisplay import fielddisplay4 from checkfield import checkfield5 from WriteData import WriteData6 7 from supportedcontrols import supportedcontrols 7 8 from supportedcostfunctions import supportedcostfunctions 8 from marshallcostfunctions import marshallcostfunctions9 from WriteData import WriteData 9 10 10 11 11 12 class m1qn3inversion(object): 12 ''' 13 M1QN3 class definition 13 """M1QN3 class definition 14 14 15 Usage:16 m1qn3inversion = m1qn3inversion()17 '''15 Usage: 16 m1qn3inversion = m1qn3inversion() 17 """ 18 18 19 19 def __init__(self, *args): # {{{ 20 21 20 if not len(args): 22 21 print('empty init') 23 22 self.iscontrol = 0 24 23 self.incomplete_adjoint = 0 25 self.control_parameters = float('NaN')26 self.control_scaling_factors = float('NaN')24 self.control_parameters = np.nan 25 self.control_scaling_factors = np.nan 27 26 self.maxsteps = 0 28 27 self.maxiter = 0 29 28 self.dxmin = 0. 30 29 self.gttol = 0. 31 self.cost_functions = float('NaN')32 self.cost_functions_coefficients = float('NaN')33 self.min_parameters = float('NaN')34 self.max_parameters = float('NaN')35 self.vx_obs = float('NaN')36 self.vy_obs = float('NaN')37 self.vz_obs = float('NaN')38 self.vel_obs = float('NaN')39 self.thickness_obs = float('NaN')30 self.cost_functions = np.nan 31 self.cost_functions_coefficients = np.nan 32 self.min_parameters = np.nan 33 self.max_parameters = np.nan 34 self.vx_obs = np.nan 35 self.vy_obs = np.nan 36 self.vz_obs = np.nan 37 self.vel_obs = np.nan 38 self.thickness_obs = np.nan 40 39 41 #set defaults42 40 self.setdefaultparameters() 43 41 elif len(args) == 1 and args[0].__module__ == 'inversion': … … 66 64 67 65 def __repr__(self): # {{{ 68 string = ' m1qn3inversion parameters:' 69 string = "%s\n%s" % (string, fielddisplay(self, 'iscontrol', 'is inversion activated?')) 70 string = "%s\n%s" % (string, fielddisplay(self, 'incomplete_adjoint', '1: linear viscosity, 0: non - linear viscosity')) 71 string = "%s\n%s" % (string, fielddisplay(self, 'control_parameters', 'ex: [''FrictionCoefficient''], or [''MaterialsRheologyBbar'']')) 72 string = "%s\n%s" % (string, fielddisplay(self, 'control_scaling_factors', 'order of magnitude of each control (useful for multi - parameter optimization)')) 73 string = "%s\n%s" % (string, fielddisplay(self, 'maxsteps', 'maximum number of iterations (gradient computation)')) 74 string = "%s\n%s" % (string, fielddisplay(self, 'maxiter', 'maximum number of Function evaluation (forward run)')) 75 string = "%s\n%s" % (string, fielddisplay(self, 'dxmin', 'convergence criterion: two points less than dxmin from eachother (sup - norm) are considered identical')) 76 string = "%s\n%s" % (string, fielddisplay(self, 'gttol', '||g(X)||/||g(X0)|| (g(X0): gradient at initial guess X0)')) 77 string = "%s\n%s" % (string, fielddisplay(self, 'cost_functions', 'indicate the type of response for each optimization step')) 78 string = "%s\n%s" % (string, fielddisplay(self, 'cost_functions_coefficients', 'cost_functions_coefficients applied to the misfit of each vertex and for each control_parameter')) 79 string = "%s\n%s" % (string, fielddisplay(self, 'min_parameters', 'absolute minimum acceptable value of the inversed parameter on each vertex')) 80 string = "%s\n%s" % (string, fielddisplay(self, 'max_parameters', 'absolute maximum acceptable value of the inversed parameter on each vertex')) 81 string = "%s\n%s" % (string, fielddisplay(self, 'vx_obs', 'observed velocity x component [m / yr]')) 82 string = "%s\n%s" % (string, fielddisplay(self, 'vy_obs', 'observed velocity y component [m / yr]')) 83 string = "%s\n%s" % (string, fielddisplay(self, 'vel_obs', 'observed velocity magnitude [m / yr]')) 84 string = "%s\n%s" % (string, fielddisplay(self, 'thickness_obs', 'observed thickness [m]')) 85 string = "%s\n%s" % (string, 'Available cost functions:') 86 string = "%s\n%s" % (string, ' 101: SurfaceAbsVelMisfit') 87 string = "%s\n%s" % (string, ' 102: SurfaceRelVelMisfit') 88 string = "%s\n%s" % (string, ' 103: SurfaceLogVelMisfit') 89 string = "%s\n%s" % (string, ' 104: SurfaceLogVxVyMisfit') 90 string = "%s\n%s" % (string, ' 105: SurfaceAverageVelMisfit') 91 string = "%s\n%s" % (string, ' 201: ThicknessAbsMisfit') 92 string = "%s\n%s" % (string, ' 501: DragCoefficientAbsGradient') 93 string = "%s\n%s" % (string, ' 502: RheologyBbarAbsGradient') 94 string = "%s\n%s" % (string, ' 503: ThicknessAbsGradient') 95 return string 96 #}}} 97 98 def extrude(self, md): # {{{ 99 self.vx_obs = project3d(md, 'vector', self.vx_obs, 'type', 'node') 100 self.vy_obs = project3d(md, 'vector', self.vy_obs, 'type', 'node') 101 self.vel_obs = project3d(md, 'vector', self.vel_obs, 'type', 'node') 102 self.thickness_obs = project3d(md, 'vector', self.thickness_obs, 'type', 'node') 103 if not np.any(np.isnan(self.cost_functions_coefficients)): 104 self.cost_functions_coefficients = project3d(md, 'vector', self.cost_functions_coefficients, 'type', 'node') 105 if not np.any(np.isnan(self.min_parameters)): 106 self.min_parameters = project3d(md, 'vector', self.min_parameters, 'type', 'node') 107 if not np.any(np.isnan(self.max_parameters)): 108 self.max_parameters = project3d(md, 'vector', self.max_parameters, 'type', 'node') 109 return self 66 s = ' m1qn3inversion parameters:\n' 67 s += '{}\n'.format(fielddisplay(self, 'iscontrol', 'is inversion activated?')) 68 s += '{}\n'.format(fielddisplay(self, 'incomplete_adjoint', '1: linear viscosity, 0: non - linear viscosity')) 69 s += '{}\n'.format(fielddisplay(self, 'control_parameters', 'ex: [''FrictionCoefficient''], or [''MaterialsRheologyBbar'']')) 70 s += '{}\n'.format(fielddisplay(self, 'control_scaling_factors', 'order of magnitude of each control (useful for multi - parameter optimization)')) 71 s += '{}\n'.format(fielddisplay(self, 'maxsteps', 'maximum number of iterations (gradient computation)')) 72 s += '{}\n'.format(fielddisplay(self, 'maxiter', 'maximum number of Function evaluation (forward run)')) 73 s += '{}\n'.format(fielddisplay(self, 'dxmin', 'convergence criterion: two points less than dxmin from eachother (sup - norm) are considered identical')) 74 s += '{}\n'.format(fielddisplay(self, 'gttol', '||g(X)||/||g(X0)|| (g(X0): gradient at initial guess X0)')) 75 s += '{}\n'.format(fielddisplay(self, 'cost_functions', 'indicate the type of response for each optimization step')) 76 s += '{}\n'.format(fielddisplay(self, 'cost_functions_coefficients', 'cost_functions_coefficients applied to the misfit of each vertex and for each control_parameter')) 77 s += '{}\n'.format(fielddisplay(self, 'min_parameters', 'absolute minimum acceptable value of the inversed parameter on each vertex')) 78 s += '{}\n'.format(fielddisplay(self, 'max_parameters', 'absolute maximum acceptable value of the inversed parameter on each vertex')) 79 s += '{}\n'.format(fielddisplay(self, 'vx_obs', 'observed velocity x component [m / yr]')) 80 s += '{}\n'.format(fielddisplay(self, 'vy_obs', 'observed velocity y component [m / yr]')) 81 s += '{}\n'.format(fielddisplay(self, 'vel_obs', 'observed velocity magnitude [m / yr]')) 82 s += '{}\n'.format(fielddisplay(self, 'thickness_obs', 'observed thickness [m]')) 83 s += '{}\n'.format('Available cost functions:') 84 s += '{}\n'.format(' 101: SurfaceAbsVelMisfit') 85 s += '{}\n'.format(' 102: SurfaceRelVelMisfit') 86 s += '{}\n'.format(' 103: SurfaceLogVelMisfit') 87 s += '{}\n'.format(' 104: SurfaceLogVxVyMisfit') 88 s += '{}\n'.format(' 105: SurfaceAverageVelMisfit') 89 s += '{}\n'.format(' 201: ThicknessAbsMisfit') 90 s += '{}\n'.format(' 501: DragCoefficientAbsGradient') 91 s += '{}\n'.format(' 502: RheologyBbarAbsGradient') 92 s += '{}\n'.format(' 503: ThicknessAbsGradient') 93 return s 110 94 #}}} 111 95 … … 130 114 #}}} 131 115 116 def extrude(self, md): # {{{ 117 self.vx_obs = project3d(md, 'vector', self.vx_obs, 'type', 'node') 118 self.vy_obs = project3d(md, 'vector', self.vy_obs, 'type', 'node') 119 self.vel_obs = project3d(md, 'vector', self.vel_obs, 'type', 'node') 120 self.thickness_obs = project3d(md, 'vector', self.thickness_obs, 'type', 'node') 121 if not np.any(np.isnan(self.cost_functions_coefficients)): 122 self.cost_functions_coefficients = project3d(md, 'vector', self.cost_functions_coefficients, 'type', 'node') 123 if not np.any(np.isnan(self.min_parameters)): 124 self.min_parameters = project3d(md, 'vector', self.min_parameters, 'type', 'node') 125 if not np.any(np.isnan(self.max_parameters)): 126 self.max_parameters = project3d(md, 'vector', self.max_parameters, 'type', 'node') 127 return self 128 #}}} 129 132 130 def checkconsistency(self, md, solution, analyses): # {{{ 133 # Early return131 # Early return 134 132 if not self.iscontrol: 135 133 return md … … 153 151 if solution == 'BalancethicknessSolution': 154 152 md = checkfield(md, 'fieldname', 'inversion.thickness_obs', 'size', [md.mesh.numberofvertices], 'NaN', 1, 'Inf', 1) 153 elif solution == 'BalancethicknessSoftSolution': 154 md = checkfield(md, 'fieldname', 'inversion.thickness_obs', 'size', [md.mesh.numberofvertices], 'NaN', 1, 'Inf', 1) 155 155 else: 156 156 md = checkfield(md, 'fieldname', 'inversion.vx_obs', 'size', [md.mesh.numberofvertices], 'NaN', 1, 'Inf', 1) 157 157 md = checkfield(md, 'fieldname', 'inversion.vy_obs', 'size', [md.mesh.numberofvertices], 'NaN', 1, 'Inf', 1) 158 159 158 return md 160 159 # }}} … … 180 179 WriteData(fid, prefix, 'object', self, 'class', 'inversion', 'fieldname', 'thickness_obs', 'format', 'DoubleMat', 'mattype', 1) 181 180 182 #process control parameters181 # Process control parameters 183 182 num_control_parameters = len(self.control_parameters) 184 183 WriteData(fid, prefix, 'object', self, 'fieldname', 'control_parameters', 'format', 'StringArray') 185 184 WriteData(fid, prefix, 'data', num_control_parameters, 'name', 'md.inversion.num_control_parameters', 'format', 'Integer') 186 185 187 #process cost functions186 # Process cost functions 188 187 num_cost_functions = np.size(self.cost_functions) 189 188 data = marshallcostfunctions(self.cost_functions) -
issm/trunk-jpl/src/m/classes/masstransport.py
r24292 r25688 1 1 import numpy as np 2 3 from checkfield import checkfield 2 4 from fielddisplay import fielddisplay 3 5 from project3d import project3d 4 from checkfield import checkfield5 6 from WriteData import WriteData 6 7 7 8 8 9 class masstransport(object): 9 """ 10 MASSTRANSPORT class definition 10 """MASSTRANSPORT class definition 11 11 12 13 12 Usage: 13 masstransport = masstransport() 14 14 """ 15 15 … … 24 24 self.requested_outputs = [] 25 25 26 #set defaults26 # Set defaults 27 27 self.setdefaultparameters() 28 28 … … 30 30 31 31 def __repr__(self): # {{{ 32 string = ' Masstransport solution parameters:' 33 string = "%s\n%s" % (string, fielddisplay(self, 'spcthickness', 'thickness constraints (NaN means no constraint) [m]')) 34 string = "%s\n%s" % (string, fielddisplay(self, 'isfreesurface', 'do we use free surfaces (FS only) or mass conservation')) 35 string = "%s\n%s" % (string, fielddisplay(self, 'min_thickness', 'minimum ice thickness allowed [m]')) 36 string = "%s\n%s" % (string, fielddisplay(self, 'hydrostatic_adjustment', 'adjustment of ice shelves surface and bed elevations: ''Incremental'' or ''Absolute'' ')) 37 string = "%s\n%s" % (string, fielddisplay(self, 'stabilization', '0: no, 1: artificial_diffusivity, 2: streamline upwinding, 3: discontinuous Galerkin, 4: Flux Correction Transport')) 38 string = "%s\n%s" % (string, fielddisplay(self, 'requested_outputs', 'additional outputs requested')) 39 40 return string 32 s = ' Masstransport solution parameters:\n' 33 s += '{}\n'.format(fielddisplay(self, 'spcthickness', 'thickness constraints (NaN means no constraint) [m]')) 34 s += '{}\n'.format(fielddisplay(self, 'isfreesurface', 'do we use free surfaces (FS only) or mass conservation')) 35 s += '{}\n'.format(fielddisplay(self, 'min_thickness', 'minimum ice thickness allowed [m]')) 36 s += '{}\n'.format(fielddisplay(self, 'hydrostatic_adjustment', 'adjustment of ice shelves surface and bed elevations: ''Incremental'' or ''Absolute'' ')) 37 s += '{}\n'.format(fielddisplay(self, 'stabilization', '0: no, 1: artificial_diffusivity, 2: streamline upwinding, 3: discontinuous Galerkin, 4: Flux Correction Transport')) 38 s += '{}\n'.format(fielddisplay(self, 'requested_outputs', 'additional outputs requested')) 39 return s 41 40 #}}} 42 41 … … 51 50 #}}} 52 51 def setdefaultparameters(self): # {{{ 53 # Type of stabilization to use 0:nothing 1:artificial_diffusivity 3:Discontinuous Galerkin52 # Type of stabilization to use 0:nothing 1:artificial_diffusivity 3:Discontinuous Galerkin 54 53 self.stabilization = 1 55 # Factor applied to compute the penalties kappa = max(stiffness matrix) * 1.0**penalty_factor54 # Factor applied to compute the penalties kappa = max(stiffness matrix) * 1.0**penalty_factor 56 55 self.penalty_factor = 3 57 # Minimum ice thickness that can be used56 # Minimum ice thickness that can be used 58 57 self.min_thickness = 1 59 # Hydrostatic adjustment58 # Hydrostatic adjustment 60 59 self.hydrostatic_adjustment = 'Absolute' 61 # default output60 # Default output 62 61 self.requested_outputs = ['default'] 63 62 return self … … 65 64 66 65 def checkconsistency(self, md, solution, analyses): # {{{ 67 # Early return66 # Early return 68 67 if ('MasstransportAnalysis' not in analyses) or (solution == 'TransientSolution' and not md.transient.ismasstransport): 69 68 return md … … 90 89 WriteData(fid, prefix, 'object', self, 'fieldname', 'penalty_factor', 'format', 'Double') 91 90 92 #process requested outputs91 # Process requested outputs 93 92 outputs = self.requested_outputs 94 93 indices = [i for i, x in enumerate(outputs) if x == 'default'] -
issm/trunk-jpl/src/m/classes/mismipbasalforcings.py
r24261 r25688 1 import numpy as np 2 3 from checkfield import checkfield 1 4 from fielddisplay import fielddisplay 2 5 from project3d import project3d 3 from checkfield import checkfield4 6 from WriteData import WriteData 5 import numpy as np6 7 7 8 8 9 class mismipbasalforcings(object): 9 """ 10 MISMIP Basal Forcings class definition 10 """MISMIP Basal Forcings class definition 11 11 12 12 Usage: 13 mismipbasalforcings = mismipbasalforcings()13 mismipbasalforcings = mismipbasalforcings() 14 14 """ 15 15 16 16 def __init__(self): # {{{ 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')17 self.groundedice_melting_rate = np.nan 18 self.meltrate_factor = np.nan 19 self.threshold_thickness = np.nan 20 self.upperdepth_melt = np.nan 21 self.geothermalflux = np.nan 22 22 self.setdefaultparameters() 23 24 23 #}}} 25 24 26 25 def __repr__(self): # {{{ 27 s tring = " MISMIP + basal melt parameterization\n"28 s tring = "%s\n%s" % (string,fielddisplay(self, "groundedice_melting_rate", "basal melting rate (positive if melting) [m / yr]"))29 s tring = "%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 s tring = "%s\n%s" % (string,fielddisplay(self, "threshold_thickness", "Threshold thickness for saturation of basal melting [m]"))31 s tring = "%s\n%s" % (string,fielddisplay(self, "upperdepth_melt", "Depth above which melt rate is zero [m]"))32 s tring = "%s\n%s" % (string,fielddisplay(self, "geothermalflux", "Geothermal heat flux [W / m^2]"))33 return s tring26 s = ' MISMIP + basal melt parameterization\n' 27 s += '{}\n'.format(fielddisplay(self, "groundedice_melting_rate", "basal melting rate (positive if melting) [m / yr]")) 28 s += '{}\n'.format(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)")) 29 s += '{}\n'.format(fielddisplay(self, "threshold_thickness", "Threshold thickness for saturation of basal melting [m]")) 30 s += '{}\n'.format(fielddisplay(self, "upperdepth_melt", "Depth above which melt rate is zero [m]")) 31 s += '{}\n'.format(fielddisplay(self, "geothermalflux", "Geothermal heat flux [W / m^2]")) 32 return s 34 33 #}}} 35 34 … … 43 42 if np.all(np.isnan(self.groundedice_melting_rate)): 44 43 self.groundedice_melting_rate = np.zeros((md.mesh.numberofvertices)) 45 print(' 44 print('no basalforcings.groundedice_melting_rate specified: values set as zero') 46 45 if np.all(np.isnan(self.geothermalflux)): 47 46 self.geothermalflux = np.zeros((md.mesh.numberofvertices)) … … 59 58 60 59 def checkconsistency(self, md, solution, analyses): # {{{ 61 # Early return62 if 'MasstransportAnalysis' in analyses and not (solution == 'TransientSolution' and md.transient.ismasstransport == 0):60 # Early return 61 if 'MasstransportAnalysis' in analyses and not solution == 'TransientSolution' and not md.transient.ismasstransport: 63 62 md = checkfield(md, 'fieldname', 'basalforcings.groundedice_melting_rate', 'NaN', 1, 'Inf', 1, 'timeseries', 1) 64 63 md = checkfield(md, 'fieldname', 'basalforcings.meltrate_factor', '>=', 0, 'numel', [1]) 65 64 md = checkfield(md, 'fieldname', 'basalforcings.threshold_thickness', '>=', 0, 'numel', [1]) 66 65 md = checkfield(md, 'fieldname', 'basalforcings.upperdepth_melt', '<=', 0, 'numel', [1]) 67 68 66 if 'BalancethicknessAnalysis' in analyses: 69 67 md = checkfield(md, 'fieldname', 'basalforcings.groundedice_melting_rate', 'NaN', 1, 'Inf', 1, 'size', [md.mesh.numberofvertices]) … … 71 69 md = checkfield(md, 'fieldname', 'basalforcings.threshold_thickness', '>=', 0, 'numel', [1]) 72 70 md = checkfield(md, 'fieldname', 'basalforcings.upperdepth_melt', '<=', 0, 'numel', [1]) 73 74 if 'ThermalAnalysis' in analyses and not (solution == 'TransientSolution' and md.transient.isthermal == 0): 71 if 'ThermalAnalysis' in analyses and not (solution == 'TransientSolution' and not md.transient.isthermal): 75 72 md = checkfield(md, 'fieldname', 'basalforcings.groundedice_melting_rate', 'NaN', 1, 'Inf', 1, 'timeseries', 1) 76 73 md = checkfield(md, 'fieldname', 'basalforcings.meltrate_factor', '>=', 0, 'numel', [1]) … … 85 82 if yts != 365.2422 * 24. * 3600.: 86 83 print('WARNING: value of yts for MISMIP + runs different from ISSM default!') 87 88 84 WriteData(fid, prefix, 'name', 'md.basalforcings.model', 'data', 3, 'format', 'Integer') 89 85 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', yts) -
issm/trunk-jpl/src/m/classes/nodalvalue.m
r21445 r25688 60 60 function md = marshall(self,prefix,md,fid) % {{{ 61 61 62 WriteData(fid,prefix,'data',self.name,'name','md.nodalvalue.name','format','String');63 WriteData(fid,prefix,'data',self.definitionstring,'name','md.nodalvalue.definitionenum','format','String');64 WriteData(fid,prefix,'data',self.model_string,'name','md.nodalvalue.model_enum','format','String');65 WriteData(fid,prefix,'data',self.node,'name','md.nodalvalue.node','format','Integer');62 WriteData(fid,prefix,'data',self.name,'name','md.nodalvalue.name','format','String'); 63 WriteData(fid,prefix,'data',self.definitionstring,'name','md.nodalvalue.definitionenum','format','String'); 64 WriteData(fid,prefix,'data',self.model_string,'name','md.nodalvalue.model_enum','format','String'); 65 WriteData(fid,prefix,'data',self.node,'name','md.nodalvalue.node','format','Integer'); 66 66 67 67 end % }}} -
issm/trunk-jpl/src/m/classes/nodalvalue.py
r25169 r25688 3 3 from checkfield import checkfield 4 4 from fielddisplay import fielddisplay 5 from pairoptions import pairoptions 5 6 from WriteData import WriteData 6 7 7 8 8 class dslmme(object): 9 ''' 10 NODALVALUE class definition 9 class nodalvalue(object): 10 """NODALVALUE class definition 11 11 12 13 14 15 16 17 18 19 20 '''12 Usage: 13 nodalvalue=nodalvalue() 14 nodalvalue=nodalvalue( 15 'name', 'SealevelriseSNodalValue', 16 'definitionstring', 'Outputdefinition1', 17 'model_string', 'SealevelriseS', 18 'node', 1 19 ) 20 """ 21 21 22 22 def __init__(self, *args): #{{{ 23 23 self.name = '' 24 self.definitionstring = '' # string that identifies this output definition uniquely, from 'Outputdefinition[1-10]'25 self.model_string = '' # string for field that is being retrieved24 self.definitionstring = '' # string that identifies this output definition uniquely, from 'Outputdefinition[1-10]' 25 self.model_string = '' # string for field that is being retrieved 26 26 self.node = np.nan #for which node are we retrieving the value? 27 27 … … 29 29 options = pairoptions(*args) 30 30 31 # get name32 self.name = options.getfieldvalue( options,'name', '')33 self.definitionstring = options.getfieldvalue( options,'definitionstring', '')34 self.model_string = options.getfieldvalue( options,'model_string', '')35 self.node = options.getfieldvalue( options,'node', '')31 # Get name 32 self.name = options.getfieldvalue('name', '') 33 self.definitionstring = options.getfieldvalue('definitionstring', '') 34 self.model_string = options.getfieldvalue('model_string', '') 35 self.node = options.getfieldvalue('node', '') 36 36 #}}} 37 37 … … 42 42 s += '{}\n'.format(fielddisplay(self, 'model_string', 'string for field that is being retrieved')) 43 43 s += '{}\n'.format(fielddisplay(self, 'node', 'vertex index at which we retrieve the value')) 44 45 44 return s 46 45 #}}} 47 46 48 47 def setdefaultparameters(self): # {{{ 49 return 48 return self 50 49 #}}} 51 50 … … 55 54 OutputdefinitionStringArray = [] 56 55 for i in range(100): 57 OutputdefinitionStringArray [i] = 'Outputdefinition{}'.format(i)56 OutputdefinitionStringArray.append('Outputdefinition{}'.format(i)) 58 57 md = checkfield(md, 'fieldname', 'self.definitionstring', 'field', self.definitionstring, 'values', OutputdefinitionStringArray) 59 58 md = checkfield(md, 'fieldname', 'self.node', 'field', self.node, 'values', range(md.mesh.numberofvertices)) 60 61 59 return md 62 60 #}}} -
issm/trunk-jpl/src/m/classes/plumebasalforcings.py
r24261 r25688 1 1 import numpy as np 2 3 from checkfield import checkfield 2 4 from fielddisplay import fielddisplay 3 from checkfield import checkfield 5 from project3d import project3d 6 from structtoobj import structtoobj 4 7 from WriteData import WriteData 5 from project3d import project3d6 8 7 9 8 10 class plumebasalforcings(object): 9 ''' 10 PLUME BASAL FORCINGS class definition 11 """PLUME BASAL FORCINGS class definition 11 12 12 13 14 '''13 Usage: 14 plumebasalforcings = plumebasalforcings() 15 """ 15 16 16 def __init__(self ): # {{{17 self.floatingice_melting_rate = float('NaN')18 self.groundedice_melting_rate = float('NaN')19 self.mantleconductivity = float('NaN')20 self.nusselt = float('NaN')21 self.dtbg = float('NaN')22 self.plumeradius = float('NaN')23 self.topplumedepth = float('NaN')24 self.bottomplumedepth = float('NaN')25 self.plumex = float('NaN')26 self.plumey = float('NaN')27 self.crustthickness = float('NaN')28 self.uppercrustthickness = float('NaN')29 self.uppercrustheat = float('NaN')30 self.lowercrustheat = float('NaN')17 def __init__(self, *args): # {{{ 18 self.floatingice_melting_rate = np.nan 19 self.groundedice_melting_rate = np.nan 20 self.mantleconductivity = np.nan 21 self.nusselt = np.nan 22 self.dtbg = np.nan 23 self.plumeradius = np.nan 24 self.topplumedepth = np.nan 25 self.bottomplumedepth = np.nan 26 self.plumex = np.nan 27 self.plumey = np.nan 28 self.crustthickness = np.nan 29 self.uppercrustthickness = np.nan 30 self.uppercrustheat = np.nan 31 self.lowercrustheat = np.nan 31 32 32 self.setdefaultparameters() 33 nargs = len(args) 34 if nargs == 0: 35 self.setdefaultparameters() 36 elif nargs == 1: 37 # TODO: This has not been tested 38 self = structtoobj(self, args[0]) 39 else: 40 error('constuctor not supported') 33 41 #}}} 34 42 35 43 def __repr__(self): # {{{ 36 string = ' mantle plume basal melt parameterization:' 37 38 string = "%s\n%s" % (string, fielddisplay(self, 'groundedice_melting_rate', 'basal melting rate (positive if melting) [m / yr]')) 39 string = "%s\n%s" % (string, fielddisplay(self, 'floatingice_melting_rate', 'basal melting rate (positive if melting) [m / yr]')) 40 string = "%s\n%s" % (string, fielddisplay(self, 'mantleconductivity', 'mantle heat conductivity [W / m^3]')) 41 string = "%s\n%s" % (string, fielddisplay(self, 'nusselt', 'nusselt number, ratio of mantle to plume [1]')) 42 string = "%s\n%s" % (string, fielddisplay(self, 'dtbg', 'background temperature gradient [degree / m]')) 43 string = "%s\n%s" % (string, fielddisplay(self, 'plumeradius', 'radius of the mantle plume [m]')) 44 string = "%s\n%s" % (string, fielddisplay(self, 'topplumedepth', 'depth of the mantle plume top below the crust [m]')) 45 string = "%s\n%s" % (string, fielddisplay(self, 'bottomplumedepth', 'depth of the mantle plume base below the crust [m]')) 46 string = "%s\n%s" % (string, fielddisplay(self, 'plumex', 'x coordinate of the center of the plume [m]')) 47 string = "%s\n%s" % (string, fielddisplay(self, 'plumey', 'y coordinate of the center of the plume [m]')) 48 string = "%s\n%s" % (string, fielddisplay(self, 'crustthickness', 'thickness of the crust [m]')) 49 string = "%s\n%s" % (string, fielddisplay(self, 'uppercrustthickness', 'thickness of the upper crust [m]')) 50 string = "%s\n%s" % (string, fielddisplay(self, 'uppercrustheat', 'volumic heat of the upper crust [w / m^3]')) 51 string = "%s\n%s" % (string, fielddisplay(self, 'lowercrustheat', 'volumic heat of the lowercrust [w / m^3]')) 52 53 return string 44 s = ' mantle plume basal melt parameterization:\n' 45 s += '{}\n'.format(fielddisplay(self, 'groundedice_melting_rate', 'basal melting rate (positive if melting) [m / yr]')) 46 s += '{}\n'.format(fielddisplay(self, 'floatingice_melting_rate', 'basal melting rate (positive if melting) [m / yr]')) 47 s += '{}\n'.format(fielddisplay(self, 'mantleconductivity', 'mantle heat conductivity [W / m^3]')) 48 s += '{}\n'.format(fielddisplay(self, 'nusselt', 'nusselt number, ratio of mantle to plume [1]')) 49 s += '{}\n'.format(fielddisplay(self, 'dtbg', 'background temperature gradient [degree / m]')) 50 s += '{}\n'.format(fielddisplay(self, 'plumeradius', 'radius of the mantle plume [m]')) 51 s += '{}\n'.format(fielddisplay(self, 'topplumedepth', 'depth of the mantle plume top below the crust [m]')) 52 s += '{}\n'.format(fielddisplay(self, 'bottomplumedepth', 'depth of the mantle plume base below the crust [m]')) 53 s += '{}\n'.format(fielddisplay(self, 'plumex', 'x coordinate of the center of the plume [m]')) 54 s += '{}\n'.format(fielddisplay(self, 'plumey', 'y coordinate of the center of the plume [m]')) 55 s += '{}\n'.format(fielddisplay(self, 'crustthickness', 'thickness of the crust [m]')) 56 s += '{}\n'.format(fielddisplay(self, 'uppercrustthickness', 'thickness of the upper crust [m]')) 57 s += '{}\n'.format(fielddisplay(self, 'uppercrustheat', 'volumic heat of the upper crust [w / m^3]')) 58 s += '{}\n'.format(fielddisplay(self, 'lowercrustheat', 'volumic heat of the lowercrust [w / m^3]')) 59 return s 54 60 #}}} 55 61 … … 61 67 self.floatingice_melting_rate = np.zeros((md.mesh.numberofvertices, )) 62 68 print(' no basalforcings.floatingice_melting_rate specified: values set as zero') 63 return 69 return self 64 70 #}}} 65 71 … … 71 77 72 78 def setdefaultparameters(self): # {{{ 73 # default values for melting parameterization79 # Default values for melting parameterization 74 80 self.mantleconductivity = 2.2 75 81 self.nusselt = 300 -
issm/trunk-jpl/src/m/classes/qmu.py
r25685 r25688 12 12 13 13 class qmu(object): 14 """ 15 QMU class definition 16 17 Usage: 18 qmu = qmu() 14 """QMU class definition 15 16 Usage: 17 qmu = qmu() 19 18 """ 20 19 … … 44 43 self.vertex_weight = float('NaN') 45 44 46 #set defaults47 45 self.setdefaultparameters() 48 49 46 #}}} 50 47 def __repr__(self): # {{{ 51 48 s = ' qmu parameters:\n' 52 53 s += "%s\n" % fielddisplay(self, 'isdakota', 'is qmu analysis activated?') 54 s += "%s\n" % fielddisplay(self, 'output', 'are we outputting ISSM results, default is 0') 49 s += '{}\n'.format(fielddisplay(self, 'isdakota', 'is QMU analysis activated?')) 50 s += '{}\n'.format(fielddisplay(self, 'output', 'are we outputting ISSM results, default is 0')) 55 51 maxlen = 0 56 s += " variables: (arrays of each variable class)\n"52 s += ' variables: (arrays of each variable class)\n' 57 53 58 54 # OrderedStruct's iterator returns individual name / array - of - functions pairs … … 74 70 s += " %-*s: [%ix%i] '%s'\n" % (maxlen + 1, fname, a, b, type(response[1][0])) 75 71 76 s += "%s\n" % fielddisplay(self, 'numberofresponses', 'number of responses')72 s += '{}\n'.format(fielddisplay(self, 'numberofresponses', 'number of responses')) 77 73 78 74 if type(self.method) != OrderedDict: … … 91 87 print(type(param)) 92 88 print(param) 93 s += " params: (array of method -independent parameters)\n"89 s += " params: (array of method-independent parameters)\n" 94 90 fnames = vars(param) 95 91 maxlen = 0 … … 116 112 s += " %-*s: [%ix%i] '%s'\n" % (maxlen + 1, fname, a, b, type(getattr(result, fname))) 117 113 118 s += "%s\n" % fielddisplay(self, 'variablepartitions', '') 119 s += "%s\n" % fielddisplay(self, 'variablepartitions_npart', '') 120 s += "%s\n" % fielddisplay(self, 'variablepartitions_nt', '') 121 s += "%s\n" % fielddisplay(self, 'variabledescriptors', '') 122 s += "%s\n" % fielddisplay(self, 'responsedescriptors', '') 123 s += "%s\n" % fielddisplay(self, 'method', 'array of dakota_method class') 124 s += "%s\n" % fielddisplay(self, 'mass_flux_profile_directory', 'directory for mass flux profiles') 125 s += "%s\n" % fielddisplay(self, 'mass_flux_profiles', 'list of mass_flux profiles') 126 s += "%s\n" % fielddisplay(self, 'mass_flux_segments', '') 127 s += "%s\n" % fielddisplay(self, 'adjacency', '') 128 s += "%s\n" % fielddisplay(self, 'vertex_weight', 'weight applied to each mesh vertex') 129 114 s += '{}\n'.format(fielddisplay(self, 'variablepartitions', '')) 115 s += '{}\n'.format(fielddisplay(self, 'variablepartitions_npart', '')) 116 s += '{}\n'.format(fielddisplay(self, 'variablepartitions_nt', '')) 117 s += '{}\n'.format(fielddisplay(self, 'variabledescriptors', '')) 118 s += '{}\n'.format(fielddisplay(self, 'responsedescriptors', '')) 119 s += '{}\n'.format(fielddisplay(self, 'method', 'array of dakota_method class')) 120 s += '{}\n'.format(fielddisplay(self, 'mass_flux_profile_directory', 'directory for mass flux profiles')) 121 s += '{}\n'.format(fielddisplay(self, 'mass_flux_profiles', 'list of mass_flux profiles')) 122 s += '{}\n'.format(fielddisplay(self, 'mass_flux_segments', '')) 123 s += '{}\n'.format(fielddisplay(self, 'adjacency', '')) 124 s += '{}\n'.format(fielddisplay(self, 'vertex_weight', 'weight applied to each mesh vertex')) 130 125 return s 131 126 # }}} -
issm/trunk-jpl/src/m/classes/qmu/normal_uncertain.m
r25222 r25688 161 161 end % }}} 162 162 %new methods: 163 163 function distributed=isdistributed(self) % {{{ 164 164 if strncmp(self.descriptor,'distributed_',12), 165 165 distributed=1; … … 168 168 end 169 169 end % }}} 170 function scaled=isscaled(self) % {{{170 function scaled=isscaled(self) % {{{ 171 171 if strncmp(self.descriptor,'scaled_',7), 172 172 scaled=1; -
issm/trunk-jpl/src/m/classes/qmu/normal_uncertain.py
r25097 r25688 10 10 11 11 class normal_uncertain(object): 12 ''' 13 NORMAL_UNCERTAIN class definition 12 """NORMAL_UNCERTAIN class definition 14 13 15 14 Usage: … … 38 37 'partition',vpartition 39 38 ) 40 ''' 39 """ 40 41 41 def __init__(self): #{{{ 42 42 self.descriptor = '' … … 231 231 232 232 #new methods: 233 def isdistributed(self): #{{{ 234 if strncmp(self.descriptor, 'distributed_', 12): 235 return True 236 else: 237 return False 238 #}}} 239 233 240 def isscaled(self): #{{{ 234 241 if strncmp(self.descriptor, 'scaled_', 7): -
issm/trunk-jpl/src/m/classes/qmu/response_function.m
r24998 r25688 116 116 end % }}} 117 117 %new methods: 118 function scaled =isscaled(self) % {{{119 if strncmp(self.descriptor,'scaled_',7),120 scaled=1;121 else122 scaled=0;123 end124 end % }}}118 function scaled =isscaled(self) % {{{ 119 if strncmp(self.descriptor,'scaled_',7), 120 scaled=1; 121 else 122 scaled=0; 123 end 124 end % }}} 125 125 end 126 126 methods (Static) -
issm/trunk-jpl/src/m/classes/qmustatistics.m
r25649 r25688 117 117 for i=1:length(self.method), 118 118 m=self.method(i); 119 WriteData(fid,prefix,'name',sprintf('md.qmu.statistics.method(%i).name',i),'data',m.name,' Format','String');119 WriteData(fid,prefix,'name',sprintf('md.qmu.statistics.method(%i).name',i),'data',m.name,'format','String'); 120 120 WriteData(fid,prefix,'data',m.fields,'name',sprintf('md.qmu.statistics.method(%i).fields',i),'format','StringArray'); 121 121 WriteData(fid,prefix,'data',m.steps,'name',sprintf('md.qmu.statistics.method(%i).steps',i),'format','IntMat','mattype',3); -
issm/trunk-jpl/src/m/classes/qmustatistics.py
r25685 r25688 26 26 # fields : fields for the statistics being requested, ex: 'Sealevel', 'BslrIce', 'BsrlHydro' 27 27 # steps : time steps at which each field statistic is computed, ex: [1, 2, 5, 20] or [range(1:100)] 28 # nbins : number of bins for 'Hist gogram' statistics28 # nbins : number of bins for 'Histogram' statistics 29 29 # indices : vertex indices at which to retrieve samples 30 30 31 31 nargs = len(args) 32 33 32 if nargs == 0: 34 33 # Create a default object 35 34 self.setdefaultparameters() 36 35 elif nargs == 1: 37 # NOTE: The following has not been tested. Remove this note when it has .36 # NOTE: The following has not been tested. Remove this note when it has 38 37 inputstruct = args[0] 39 38 list1 = properties('qmustatistics') … … 48 47 49 48 def __repr__(self): # {{{ 50 s = '{}\n'.format('qmustatistics: post-Dakota run processing of QMU statistics:') 51 49 s = 'qmustatistics: post-Dakota run processing of QMU statistics:\n' 52 50 if self.method[0]['name'] == 'None': 53 51 return s 54 55 52 s += '{}\n'.format(fielddisplay(self, 'nfiles_per_directory', 'number of files per output directory')) 56 53 s += '{}\n'.format(fielddisplay(self, 'ndirectories', 'number of output directories; should be < numcpus')) 57 58 54 for i in range(len(self.method)): 59 55 s += '{}\n'.format(' method # {}'.format(i)) 60 56 s += '{}\n'.format(self.method[i]) 61 62 57 return s 63 58 #}}} … … 67 62 self.nfiles_per_directory = 5 # Number of files per output directory 68 63 self.ndirectories = 50 # Number of output directories; should be < numcpus 64 return self 69 65 #}}} 70 66 … … 115 111 WriteData(fid, prefix, 'name', 'md.qmu.statistics.ndirectories', 'data', self.ndirectories, 'format', 'Integer') 116 112 WriteData(fid, prefix, 'name', 'md.qmu.statistics.numstatistics', 'data', len(self.method), 'format', 'Integer') 117 for i in range(len(self.method)): 118 m = self.method[i] 119 WriteData(fid, prefix, 'name', 'md.qmu.statistics.method[{}][\'name\']'.format(i), 'data', m['name'], 'Format', 'String') 120 WriteData(fid, prefix, 'data', m['fields'], 'name', 'md.qmu.statistics.method[{}][\'fields\']'.format(i), 'format', 'StringArray') 121 WriteData(fid, prefix, 'data', m['steps'], 'name', 'md.qmu.statistics.method[{}][\'steps\']'.format(i), 'format', 'IntMat', 'mattype', 3) 122 113 for i in range(1, len(self.method) + 1): 114 m = self.method[i - 1] 115 WriteData(fid, prefix, 'name', 'md.qmu.statistics.method({}).name'.format(i), 'data', m['name'], 'format', 'String') 116 WriteData(fid, prefix, 'data', m['fields'], 'name', 'md.qmu.statistics.method({}).fields'.format(i), 'format', 'StringArray') 117 WriteData(fid, prefix, 'data', m['steps'], 'name', 'md.qmu.statistics.method({}).steps'.format(i), 'format', 'IntMat', 'mattype', 3) 123 118 if m['name'] == 'Histogram': 124 WriteData(fid, prefix, 'name', 'md.qmu.statistics.method [{}][\'nbins\']'.format(i), 'data', m['nbins'], 'format', 'Integer')119 WriteData(fid, prefix, 'name', 'md.qmu.statistics.method({}).nbins'.format(i), 'data', m['nbins'], 'format', 'Integer') 125 120 elif m['name'] == 'MeanVariance': 126 121 pass # do nothing 127 122 elif m['name'] == 'SampleSeries': 128 WriteData(fid, prefix, 'data', m['indices'], 'name', 'md.qmu.statistics.method [{}][\'indices\']'.format(i), 'format', 'IntMat', 'mattype', 3)123 WriteData(fid, prefix, 'data', m['indices'], 'name', 'md.qmu.statistics.method({}).indices'.format(i), 'format', 'IntMat', 'mattype', 3) 129 124 else: 130 125 raise Exception('qmustatistics marshall error message: unknown type ''{}'' for qmu.statistics.method[{}]'.format(m['name'], i)) … … 134 129 return self 135 130 #}}} 131 132 def addmethod(self, *args): #{{{ 133 """ADDMETHOD - Add new, empty method or passed dict to self.method 134 """ 135 nargs = len(args) 136 if nargs == 0: 137 self.method.append({}) 138 elif nargs == 1: 139 self.method.append(args[0]) 140 else: 141 raise Exception('Number of args should be 0 (appends empty dict to methods member) or 1 (appends passed dict to methods member)') 142 #}}} -
issm/trunk-jpl/src/m/classes/results.py
r25168 r25688 3 3 4 4 class results(object): 5 ''' 6 RESULTS class definition 5 """RESULTS class definition 7 6 8 9 7 Usage: 8 results = results() 10 9 11 12 10 TODO: 11 - Modify output so that it matches that of 13 12 14 13 disp(md.results.<<solutionstring>>) 15 14 16 17 '''15 where <<solutionstring>> is one of the values from solve.m 16 """ 18 17 19 18 def __init__(self, *args): # {{{ -
issm/trunk-jpl/src/m/classes/rotational.py
r25171 r25688 7 7 8 8 class rotational(object): 9 ''' 10 ROTATIONAL class definition 9 """ROTATIONAL class definition 11 10 12 13 14 '''11 Usage: 12 rotational = rotational() 13 """ 15 14 16 15 def __init__(self, *args): #{{{ … … 20 19 21 20 nargin = len(args) 22 23 21 if nargin == 0: 24 22 self.setdefaultparameters() … … 32 30 s += '{}\n'.format(fielddisplay(self, 'polarmoi', 'polar moment of inertia [kg m^2]')) 33 31 s += '{}\n'.format(fielddisplay(self, 'angularvelocity', 'mean rotational velocity of earth [per second]')) 34 35 32 return s 36 33 #}}} 37 34 38 35 def setdefaultparameters(self): # {{{ 39 # moment of inertia36 # Moment of inertia 40 37 self.equatorialmoi = 8.0077e37 # [kg m^2] 41 38 self.polarmoi = 8.0345e37 # [kg m^2] 42 39 43 # mean rotational velocity of earth40 # Mean rotational velocity of earth 44 41 self.angularvelocity = 7.2921e-5 # [s^-1] 42 return self 45 43 #}}} 46 44 47 45 def checkconsistency(self, md, solution, analyses): # {{{ 48 if ('SealevelriseAnalysis' not in analyses) or (solution == 'TransientSolution' and md.transient.isslr == 0):46 if ('SealevelriseAnalysis' not in analyses) or (solution == 'TransientSolution' and not md.transient.isslr): 49 47 return md 50 51 48 md = checkfield(md, 'fieldname', 'solidearth.rotational.equatorialmoi', 'NaN', 1, 'Inf', 1) 52 49 md = checkfield(md, 'fieldname', 'solidearth.rotational.polarmoi', 'NaN', 1, 'Inf', 1) 53 50 md = checkfield(md, 'fieldname', 'solidearth.rotational.angularvelocity', 'NaN', 1, 'Inf', 1) 54 55 51 return md 56 52 #}}} -
issm/trunk-jpl/src/m/classes/sealevelmodel.m
r25677 r25688 27 27 methods 28 28 function slm = sealevelmodel(varargin) % {{{ 29 30 if nargin==0, 31 slm=setdefaultparameters(slm); 32 else 33 slm=setdefaultparameters(slm); 34 35 options=pairoptions(varargin{:}); 36 29 slm=setdefaultparameters(slm); 30 31 if nargin==1, 32 33 options=pairoptions(varargin{:}); 34 37 35 %recover all the icecap models: 38 36 slm.icecaps=getfieldvalues(options,'ice_cap',{}); … … 419 417 420 418 end % }}} 421 function viscousiterations(self) % {{{422 for i=1:length(self.icecaps),423 ic=self.icecaps{i};424 mvi=ic.results.TransientSolution(1).StressbalanceConvergenceNumSteps;425 for j=2:length(ic.results.TransientSolution)-1,426 mvi=max(mvi,ic.results.TransientSolution(j).StressbalanceConvergenceNumSteps);427 end428 disp(sprintf('%i, %s: %i',i,self.icecaps{i}.miscellaneous.name,mvi));429 end430 end % }}}419 function viscousiterations(self) % {{{ 420 for i=1:length(self.icecaps), 421 ic=self.icecaps{i}; 422 mvi=ic.results.TransientSolution(1).StressbalanceConvergenceNumSteps; 423 for j=2:length(ic.results.TransientSolution)-1, 424 mvi=max(mvi,ic.results.TransientSolution(j).StressbalanceConvergenceNumSteps); 425 end 426 disp(sprintf('%i, %s: %i',i,self.icecaps{i}.miscellaneous.name,mvi)); 427 end 428 end % }}} 431 429 function maxtimestep(self) % {{{ 432 430 for i=1:length(self.icecaps), 433 ic=self.icecaps{i}; 431 ic=self.icecaps{i}; 434 432 mvi=length(ic.results.TransientSolution); 435 433 timei=ic.results.TransientSolution(end).time; -
issm/trunk-jpl/src/m/classes/sealevelmodel.py
r25679 r25688 1 1 from copy import deepcopy 2 2 import warnings 3 3 4 import numpy as np 5 4 6 from fielddisplay import fielddisplay 5 7 from generic import generic … … 47 49 self.planet = '' 48 50 49 # Create a default object50 51 self.setdefaultparameters() 51 52 52 53 if len(args): 53 # Use provided options to set fields54 54 options = pairoptions(*args) 55 55 … … 90 90 # Is the coupler turned on? 91 91 for i in range(len(slm.icecaps)): 92 if slm.icecaps[i].transient.iscoupler == 0:92 if not slm.icecaps[i].transient.iscoupler: 93 93 warnings.warn('sealevelmodel checkconsistency error: icecap model {} should have the transient coupler option turned on!'.format(slm.icecaps[i].miscellaneous.name)) 94 94 95 if slm.earth.transient.iscoupler == 0:95 if not slm.earth.transient.iscoupler: 96 96 warnings.warn('sealevelmodel checkconsistency error: earth model should have the transient coupler option turned on!') 97 97 … … 99 99 for i in range(len(slm.icecaps)): 100 100 if slm.icecaps[i].mesh.numberofvertices != len(slm.earth.slr.transitions[i]): 101 raise RuntimeError('sealevelmodel checkconsistency issue with size of transition vector for ice cap: {} name: {}'.format(i, slm.icecaps[i].miscellaneous.name))101 raise Exception('sealevelmodel checkconsistency issue with size of transition vector for ice cap: {} name: {}'.format(i, slm.icecaps[i].miscellaneous.name)) 102 102 103 103 # Check that run frequency is the same everywhere 104 104 for i in range(len(slm.icecaps)): 105 105 if slm.icecaps[i].slr.geodetic_run_frequency != slm.earth.geodetic_run_frequency: 106 raise RuntimeError('sealevelmodel checkconsistency error: icecap model {} should have the same run frequency as earth!'.format(slm.icecaps[i].miscellaneous.name))106 raise Exception('sealevelmodel checkconsistency error: icecap model {} should have the same run frequency as earth!'.format(slm.icecaps[i].miscellaneous.name)) 107 107 108 108 # Make sure steric_rate is the same everywhere … … 110 110 md = slm.icecaps[i] 111 111 if np.nonzero(md.slr.steric_rate - slm.earth.slr.steric_rate[slm.earth.slr.transitions[i]]) != []: 112 raise RuntimeError('steric rate on ice cap {} is not the same as for the earth'.format(md.miscellaneous.name))112 raise Exception('steric rate on ice cap {} is not the same as for the earth'.format(md.miscellaneous.name)) 113 113 #}}} 114 114 … … 168 168 def addbasin(self, bas): # {{{ 169 169 if bas.__class__.__name__ != 'basin': 170 raise RuntimeError('addbasin method only takes a \'basin\' class object as input')170 raise Exception('addbasin method only takes a \'basin\' class object as input') 171 171 self.basins.append(bas) 172 172 #}}} … … 387 387 for i in range(len(self.icecaps)): 388 388 ic = self.icecaps[i] 389 mvi = ic.resu tls.TransientSolution[0].StressbalanceConvergenceNumSteps389 mvi = ic.results.TransientSolution[0].StressbalanceConvergenceNumSteps 390 390 for j in range(1, len(ic.results.TransientSolution) - 1): 391 391 mvi = np.max(mvi, ic.results.TransientSolution[j].StressbalanceConvergenceNumSteps) … … 465 465 466 466 if not noearth: 467 ic.results.TransientSolution = ic.resu tls.TransientSolution[:mintimestep]467 ic.results.TransientSolution = ic.results.TransientSolution[:mintimestep] 468 468 469 469 self.earth = ic -
issm/trunk-jpl/src/m/classes/slr.m
r25168 r25688 136 136 %end 137 137 138 %check that 138 %check that if geodetic is requested, we are a mesh3dsurface model (planet), or if we are not, 139 139 %a coupler to a planet model is provided. 140 140 if self.geodetic, -
issm/trunk-jpl/src/m/classes/slr.py
r25171 r25688 50 50 51 51 def __repr__(self): # {{{ 52 s = ' slr parameters:' 53 s = "%s\n%s" % (s, fielddisplay(self, 'deltathickness', 'thickness change: ice height equivalent [m]')) 54 s = "%s\n%s" % (s, fielddisplay(self, 'sealevel', 'current sea level (prior to computation) [m]')) 55 s = "%s\n%s" % (s, fielddisplay(self, 'spcthickness', 'thickness constraints (NaN means no constraint) [m]')) 56 s = "%s\n%s" % (s, fielddisplay(self, 'reltol', 'sea level rise relative convergence criterion, (NaN: not applied)')) 57 s = "%s\n%s" % (s, fielddisplay(self, 'abstol', 'sea level rise absolute convergence criterion, (default, NaN: not applied)')) 58 s = "%s\n%s" % (s, fielddisplay(self, 'maxiter', 'maximum number of nonlinear iterations')) 59 s = "%s\n%s" % (s, fielddisplay(self, 'love_h', 'load Love number for radial displacement')) 60 s = "%s\n%s" % (s, fielddisplay(self, 'love_k', 'load Love number for gravitational potential perturbation')) 61 s = "%s\n%s" % (s, fielddisplay(self, 'love_l', 'load Love number for horizontal displaements')) 62 s = "%s\n%s" % (s, fielddisplay(self, 'tide_love_k', 'tidal load Love number (degree 2)')) 63 s = "%s\n%s" % (s, fielddisplay(self, 'tide_love_h', 'tidal load Love number (degree 2)')) 64 s = "%s\n%s" % (s, fielddisplay(self, 'fluid_love', 'secular fluid Love number')) 65 s = "%s\n%s" % (s, fielddisplay(self, 'equatorial_moi', 'mean equatorial moment of inertia [kg m^2]')) 66 s = "%s\n%s" % (s, fielddisplay(self, 'polar_moi', 'polar moment of inertia [kg m^2]')) 67 s = "%s\n%s" % (s, fielddisplay(self, 'angular_velocity', 'mean rotational velocity of earth [per second]')) 68 s = "%s\n%s" % (s, fielddisplay(self, 'ocean_area_scaling', 'correction for model representation of ocean area [default: No correction]')) 69 s = "%s\n%s" % (s, fielddisplay(self, 'hydro_rate', 'rate of hydrological expansion [mm / yr]')) 70 s = "%s\n%s" % (s, fielddisplay(self, 'geodetic', 'compute geodetic SLR? (in addition to steric?) default 0')) 71 s = "%s\n%s" % (s, fielddisplay(self, 'geodetic_run_frequency', 'how many time steps we skip before we run SLR solver during transient (default: 1)')) 72 s = "%s\n%s" % (s, fielddisplay(self, 'rigid', 'rigid earth graviational potential perturbation')) 73 s = "%s\n%s" % (s, fielddisplay(self, 'elastic', 'elastic earth graviational potential perturbation')) 74 s = "%s\n%s" % (s, fielddisplay(self, 'rotation', 'earth rotational potential perturbation')) 75 s = "%s\n%s" % (s, fielddisplay(self, 'degacc', 'accuracy (default .01 deg) for numerical discretization of the Green''s functions')) 76 s = "%s\n%s" % (s, fielddisplay(self, 'transitions', 'indices into parts of the mesh that will be icecaps')) 77 s = "%s\n%s" % (s, fielddisplay(self, 'requested_outputs', 'additional outputs requested')) 78 52 s = ' slr parameters:\n' 53 s += '{}\n'.format(fielddisplay(self, 'deltathickness', 'thickness change: ice height equivalent [m]')) 54 s += '{}\n'.format(fielddisplay(self, 'sealevel', 'current sea level (prior to computation) [m]')) 55 s += '{}\n'.format(fielddisplay(self, 'spcthickness', 'thickness constraints (NaN means no constraint) [m]')) 56 s += '{}\n'.format(fielddisplay(self, 'reltol', 'sea level rise relative convergence criterion, (NaN: not applied)')) 57 s += '{}\n'.format(fielddisplay(self, 'abstol', 'sea level rise absolute convergence criterion, (default, NaN: not applied)')) 58 s += '{}\n'.format(fielddisplay(self, 'maxiter', 'maximum number of nonlinear iterations')) 59 s += '{}\n'.format(fielddisplay(self, 'love_h', 'load Love number for radial displacement')) 60 s += '{}\n'.format(fielddisplay(self, 'love_k', 'load Love number for gravitational potential perturbation')) 61 s += '{}\n'.format(fielddisplay(self, 'love_l', 'load Love number for horizontal displaements')) 62 s += '{}\n'.format(fielddisplay(self, 'tide_love_k', 'tidal load Love number (degree 2)')) 63 s += '{}\n'.format(fielddisplay(self, 'tide_love_h', 'tidal load Love number (degree 2)')) 64 s += '{}\n'.format(fielddisplay(self, 'fluid_love', 'secular fluid Love number')) 65 s += '{}\n'.format(fielddisplay(self, 'equatorial_moi', 'mean equatorial moment of inertia [kg m^2]')) 66 s += '{}\n'.format(fielddisplay(self, 'polar_moi', 'polar moment of inertia [kg m^2]')) 67 s += '{}\n'.format(fielddisplay(self, 'angular_velocity', 'mean rotational velocity of earth [per second]')) 68 s += '{}\n'.format(fielddisplay(self, 'ocean_area_scaling', 'correction for model representation of ocean area [default: No correction]')) 69 s += '{}\n'.format(fielddisplay(self, 'hydro_rate', 'rate of hydrological expansion [mm / yr]')) 70 s += '{}\n'.format(fielddisplay(self, 'geodetic', 'compute geodetic SLR? (in addition to steric?) default 0')) 71 s += '{}\n'.format(fielddisplay(self, 'geodetic_run_frequency', 'how many time steps we skip before we run SLR solver during transient (default: 1)')) 72 s += '{}\n'.format(fielddisplay(self, 'rigid', 'rigid earth graviational potential perturbation')) 73 s += '{}\n'.format(fielddisplay(self, 'elastic', 'elastic earth graviational potential perturbation')) 74 s += '{}\n'.format(fielddisplay(self, 'rotation', 'earth rotational potential perturbation')) 75 s += '{}\n'.format(fielddisplay(self, 'degacc', 'accuracy (default .01 deg) for numerical discretization of the Green''s functions')) 76 s += '{}\n'.format(fielddisplay(self, 'transitions', 'indices into parts of the mesh that will be icecaps')) 77 s += '{}\n'.format(fielddisplay(self, 'requested_outputs', 'additional outputs requested')) 79 78 return s 80 79 # }}} 81 80 82 81 def setdefaultparameters(self): # {{{ 83 # Convergence criterion: absolute, relative and residual84 self.reltol = 0.01 # default85 self.abstol = np.nan # 1 mm of sea level rise86 # maximum of non - linear iterations.82 # Convergence criterion: absolute, relative and residual 83 self.reltol = 0.01 # default 84 self.abstol = np.nan # 1 mm of sea level rise 85 # Maximum number of non-linear iterations 87 86 self.maxiter = 5 88 # computational flags:87 # Computational flags 89 88 self.geodetic = 0 90 89 self.rigid = 1 … … 92 91 self.ocean_area_scaling = 0 93 92 self.rotation = 1 94 # tidal love numbers:95 self.tide_love_h = 0.6149 #degree 296 self.tide_love_k = 0.3055 #degree 297 # secular fluid love number:93 # Tidal love numbers 94 self.tide_love_h = 0.6149 # degree 2 95 self.tide_love_k = 0.3055 # degree 2 96 # Secular fluid love number 98 97 self.fluid_love = 0.942 99 # moment of inertia:98 # Moment of inertia 100 99 self.equatorial_moi = 8.0077e37 # [kg m^2] 101 100 self.polar_moi = 8.0345e37 # [kg m^2] 102 # mean rotational velocity of earth103 self.angular_velocity = 7.2921e-5 # [s^ -1]104 # numerical discretization accuracy101 # Mean rotational velocity of earth 102 self.angular_velocity = 7.2921e-5 # [s^-1] 103 # Numerical discretization accuracy 105 104 self.degacc = 0.01 106 # hydro105 # Hydro 107 106 self.hydro_rate = 0 108 # how many time steps we skip before we run SLR solver during transient107 # How many time steps we skip before we run SLR solver during transient 109 108 self.geodetic_run_frequency = 1 110 # output default:109 # Output default 111 110 self.requested_outputs = ['default'] 112 # transitions should be a cell array of vectors:111 # Transitions should be a list of vectors 113 112 self.transitions = [] 114 # horizontal displacement? (notby default)113 # Horizontal displacement? (not on by default) 115 114 self.horiz = 0 116 # earth area115 # Earth area 117 116 self.planetradius = planetradius('earth') 118 119 117 return self 120 118 #}}} 121 119 122 120 def checkconsistency(self, md, solution, analyses): # {{{ 123 # Early return124 if (solution != 'SealevelriseAnalysis') or (solution == 'TransientSolution' and md.transient.isslr == 0):121 # Early return 122 if 'SealevelriseAnalysis' not in analyses or (solution == 'TransientSolution' and not md.transient.isslr): 125 123 return md 126 124 … … 146 144 md = checkfield(md, 'fieldname', 'slr.horiz', 'NaN', 1, 'Inf', 1, 'values', [0, 1]) 147 145 148 # check that love numbers are provided at the same level of accuracy:146 # Check that love numbers are provided at the same level of accuracy: 149 147 if (size(self.love_h, 0) != size(self.love_k, 0)) or (size(self.love_h, 0) != size(self.love_l, 0)): 150 148 raise Exception('slr error message: love numbers should be provided at the same level of accuracy') 151 149 152 # cross check that whereever we have an ice load, the mask is < 0 on each vertex:150 # Cross check that whereever we have an ice load, the mask is < 0 on each vertex: 153 151 pos = np.where(self.deltathickness) 154 152 maskpos = md.mask.ice_levelset[md.mesh.elements[pos, :]] … … 157 155 warnings.warn('slr checkconsistency fail: there are elements with ice loads where some vertices are not on the ice!') 158 156 159 #check that if geodetic is requested, we are a mesh3dsurface model (planet), or if we are not, 160 #a coupler to a planet model is provided. 161 if self.geodetic and not md.transient.iscoupler and domaintype(md.mesh) != 'mesh3dsurface': 162 raise Exception('model is requesting geodetic computations without being a mesh3dsurface, or being coupled to one!') 157 # Check that if geodetic is requested, we are a mesh3dsurface model (planet), or if we are not, a coupler to a planet model is provided 158 if self.geodetic: 159 if md.transient.iscoupler: 160 # We are good 161 pass 162 else: 163 if md.mesh.__class__.__name__ == 'mesh3dsurface': 164 # We are good 165 pass 166 else: 167 raise Exception('model is requesting geodetic computations without being a mesh3dsurface, or being coupled to one!') 163 168 return md 164 169 # }}} … … 196 201 WriteData(fid, prefix, 'object', self, 'fieldname', 'planetradius', 'format', 'Double') 197 202 198 #process requested outputs203 # Process requested outputs 199 204 outputs = self.requested_outputs 200 205 indices = [i for i, x in enumerate(outputs) if x == 'default'] -
issm/trunk-jpl/src/m/classes/solidearth.py
r25485 r25688 12 12 13 13 class solidearth(object): 14 ''' 15 SOLIDEARTH class definition 14 """SOLIDEARTH class definition 16 15 17 18 19 '''16 Usage: 17 solidearth = solidearth() 18 """ 20 19 21 20 def __init__(self, *args): #{{{ … … 51 50 52 51 def setdefaultparameters(self): # {{{ 53 return 52 return self 54 53 #}}} 55 54 56 55 def checkconsistency(self, md, solution, analyses): # {{{ 57 if ('SealevelriseAnalysis' not in analyses) or (solution == 'TransientSolution' and md.transient.isslr == 0):56 if ('SealevelriseAnalysis' not in analyses) or (solution == 'TransientSolution' and not md.transient.isslr): 58 57 return md 59 60 58 md = checkfield(md, 'fieldname', 'solidearth.sealevel', 'NaN', 1, 'Inf', 1, 'size', [md.mesh.numberofvertices]) 61 59 md = checkfield(md, 'fieldname', 'solidearth.requested_outputs', 'stringrow', 1) 62 63 60 self.settings.checkconsistency(md, solution, analyses) 64 61 self.surfaceload.checkconsistency(md, solution, analyses) 65 62 self.lovenumbers.checkconsistency(md, solution, analyses) 66 63 self.rotational.checkconsistency(md, solution, analyses) 67 68 64 return md 69 65 #}}} … … 92 88 #}}} 93 89 94 def extrude(self, md): 90 def extrude(self, md): #{{{ 95 91 self.sealevel = project3d(md, 'vector', self.sealevel, 'type', 'node') 96 97 92 return self 98 93 #}}} -
issm/trunk-jpl/src/m/classes/solidearthsettings.py
r25166 r25688 7 7 8 8 class solidearthsettings(object): 9 ''' 10 SOLIDEARTHSETTINGS class definition 9 """SOLIDEARTHSETTINGS class definition 11 10 12 13 14 '''11 Usage: 12 solidearthsettings = solidearthsettings() 13 """ 15 14 16 15 def __init__(self, *args): #{{{ … … 34 33 s += '{}\n'.format(fielddisplay(self, 'elastic', 'elastic earth graviational potential perturbation')) 35 34 s += '{}\n'.format(fielddisplay(self, 'degacc', 'accuracy (default .01 deg) for numerical discretization of the Green\'s functions')) 36 37 35 return s 38 36 #}}} 39 37 40 38 def setdefaultparameters(self): # {{{ 41 # Convergence criterion: absolute, relative, and residual39 # Convergence criterion: absolute, relative, and residual 42 40 self.reltol = 0.01 # 1 percent 43 41 self.abstol = np.nan # default 44 42 45 # maximum of non-linear iterations43 # Maximum of non-linear iterations 46 44 self.maxiter = 5 47 45 48 # computational flags46 # Computational flags 49 47 self.rigid = 1 50 48 self.elastic = 1 … … 53 51 self.computesealevelchange = 0 54 52 55 # numerical discetization accuracy53 # Numerical discretization accuracy 56 54 self.degacc = .01 57 55 58 # how many time steps we skip before we run solidearthsettings solver during transient56 # How many time steps we skip before we run solidearthsettings solver during transient 59 57 self.runfrequency = 1 60 58 61 # horizontal displacemnet? (notby default)59 # Horizontal displacement? (not on by default) 62 60 self.horiz = 0 61 return self 63 62 #}}} 64 63 65 64 def checkconsistency(self, md, solution, analyses): # {{{ 66 if ('SealevelriseAnalysis' not in analyses) or (solution == 'TransientSolution' and md.transient.isslr == 0):65 if ('SealevelriseAnalysis' not in analyses) or (solution == 'TransientSolution' and not md.transient.isslr): 67 66 return md 68 69 67 md = checkfield(md, 'fieldname', 'solidearth.settings.reltol', 'size', [1]) 70 68 md = checkfield(md, 'fieldname', 'solidearth.settings.abstol', 'size', [1]) … … 74 72 md = checkfield(md, 'fieldname', 'solidearth.settings.horiz', 'NaN', 1, 'Inf', 1, 'values', [0, 1]) 75 73 76 # acoupler to planet model is provided74 # A coupler to planet model is provided 77 75 if self.computesealevelchange: 78 76 if md.transient.iscoupler: 79 # we are good77 # We are good 80 78 pass 81 79 else: 82 80 if md.mesh.__class__.__name__ == 'mesh3dsurface': 83 # we are good81 # We are good 84 82 pass 85 83 else: 86 84 raise Exception('model is requesting sealevel computations without being a mesh3dsurface, or being coupled to one!') 87 88 85 return md 89 86 #}}} -
issm/trunk-jpl/src/m/classes/spatiallinearbasalforcings.m
r22945 r25688 81 81 end % }}} 82 82 function disp(self) % {{{ 83 disp(sprintf(' basal forcings parameters:'));83 disp(sprintf(' spatial linear basal forcings parameters:')); 84 84 85 85 fielddisplay(self,'groundedice_melting_rate','basal melting rate (positive if melting) [m/yr]'); … … 100 100 floatingice_melting_rate(pos)=md.basalforcings.deepwater_melting_rate(pos).*(md.geometry.base(pos)-md.basalforcings.upperwater_elevation(pos))./(md.basalforcings.deepwater_elevation(pos)-md.basalforcings.upperwater_elevation(pos)); 101 101 WriteData(fid,prefix,'name','md.basalforcings.model','data',6,'format','Integer'); 102 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) 103 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) 102 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); 103 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); 104 104 WriteData(fid,prefix,'object',self,'fieldname','geothermalflux','name','md.basalforcings.geothermalflux','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts); 105 WriteData(fid,prefix,'object',self,'fieldname','deepwater_melting_rate','format','DoubleMat','name','md.basalforcings.deepwater_melting_rate','scale',1./yts,'mattype',1) 106 WriteData(fid,prefix,'object',self,'fieldname','deepwater_elevation','format','DoubleMat','name','md.basalforcings.deepwater_elevation','mattype',1) 107 WriteData(fid,prefix,'object',self,'fieldname','upperwater_elevation','format','DoubleMat','name','md.basalforcings.upperwater_elevation','mattype',1) 105 WriteData(fid,prefix,'object',self,'fieldname','deepwater_melting_rate','format','DoubleMat','name','md.basalforcings.deepwater_melting_rate','scale',1./yts,'mattype',1); 106 WriteData(fid,prefix,'object',self,'fieldname','deepwater_elevation','format','DoubleMat','name','md.basalforcings.deepwater_elevation','mattype',1); 107 WriteData(fid,prefix,'object',self,'fieldname','upperwater_elevation','format','DoubleMat','name','md.basalforcings.upperwater_elevation','mattype',1); 108 108 end % }}} 109 109 end -
issm/trunk-jpl/src/m/classes/stressbalance.py
r25023 r25688 1 import sys 2 1 3 import numpy as np 2 import sys 4 5 from checkfield import checkfield 6 from fielddisplay import fielddisplay 7 import MatlabFuncs as m 3 8 from project3d import project3d 4 from fielddisplay import fielddisplay5 from checkfield import checkfield6 9 from WriteData import WriteData 7 import MatlabFuncs as m8 10 9 11 10 12 class stressbalance(object): 11 """ 12 STRESSBALANCE class definition 13 """STRESSBALANCE class definition 13 14 14 15 15 Usage: 16 stressbalance = stressbalance() 16 17 """ 17 18 … … 41 42 #}}} 42 43 def __repr__(self): # {{{ 43 44 string = ' StressBalance solution parameters:' 45 string = "%s\n%s" % (string, ' Convergence criteria:') 46 string = "%s\n%s" % (string, fielddisplay(self, 'restol', 'mechanical equilibrium residual convergence criterion')) 47 string = "%s\n%s" % (string, fielddisplay(self, 'reltol', 'velocity relative convergence criterion, NaN: not applied')) 48 string = "%s\n%s" % (string, fielddisplay(self, 'abstol', 'velocity absolute convergence criterion, NaN: not applied')) 49 string = "%s\n%s" % (string, fielddisplay(self, 'isnewton', "0: Picard's fixed point, 1: Newton's method, 2: hybrid")) 50 string = "%s\n%s" % (string, fielddisplay(self, 'maxiter', 'maximum number of nonlinear iterations')) 51 52 string = "%s\n%s" % (string, '\n boundary conditions:') 53 string = "%s\n%s" % (string, fielddisplay(self, 'spcvx', 'x - axis velocity constraint (NaN means no constraint) [m / yr]')) 54 string = "%s\n%s" % (string, fielddisplay(self, 'spcvy', 'y - axis velocity constraint (NaN means no constraint) [m / yr]')) 55 string = "%s\n%s" % (string, fielddisplay(self, 'spcvz', 'z - axis velocity constraint (NaN means no constraint) [m / yr]')) 56 string = "%s\n%s" % (string, fielddisplay(self, 'icefront', 'segments on ice front list (last column 0: Air, 1: Water, 2: Ice')) 57 58 string = "%s\n%s" % (string, '\n Rift options:') 59 string = "%s\n%s" % (string, fielddisplay(self, 'rift_penalty_threshold', 'threshold for instability of mechanical constraints')) 60 string = "%s\n%s" % (string, fielddisplay(self, 'rift_penalty_lock', 'number of iterations before rift penalties are locked')) 61 62 string = "%s\n%s" % (string, '\n Penalty options:') 63 string = "%s\n%s" % (string, fielddisplay(self, 'penalty_factor', 'offset used by penalties: penalty = Kmax * 1.0**offset')) 64 string = "%s\n%s" % (string, fielddisplay(self, 'vertex_pairing', 'pairs of vertices that are penalized')) 65 66 string = "%s\n%s" % (string, '\n Other:') 67 string = "%s\n%s" % (string, fielddisplay(self, 'shelf_dampening', 'use dampening for floating ice ? Only for FS model')) 68 string = "%s\n%s" % (string, fielddisplay(self, 'FSreconditioning', 'multiplier for incompressibility equation. Only for FS model')) 69 string = "%s\n%s" % (string, fielddisplay(self, 'referential', 'local referential')) 70 string = "%s\n%s" % (string, fielddisplay(self, 'loadingforce', 'loading force applied on each point [N / m^3]')) 71 string = "%s\n%s" % (string, fielddisplay(self, 'requested_outputs', 'additional outputs requested')) 72 73 return string 44 s = ' StressBalance solution parameters:\n' 45 s += ' Convergence criteria:\n' 46 s += '{}\n'.format(fielddisplay(self, 'restol', 'mechanical equilibrium residual convergence criterion')) 47 s += '{}\n'.format(fielddisplay(self, 'reltol', 'velocity relative convergence criterion, NaN: not applied')) 48 s += '{}\n'.format(fielddisplay(self, 'abstol', 'velocity absolute convergence criterion, NaN: not applied')) 49 s += '{}\n'.format(fielddisplay(self, 'isnewton', "0: Picard's fixed point, 1: Newton's method, 2: hybrid")) 50 s += '{}\n'.format(fielddisplay(self, 'maxiter', 'maximum number of nonlinear iterations')) 51 s += ' boundary conditions:\n' 52 s += '{}\n'.format(fielddisplay(self, 'spcvx', 'x - axis velocity constraint (NaN means no constraint) [m / yr]')) 53 s += '{}\n'.format(fielddisplay(self, 'spcvy', 'y - axis velocity constraint (NaN means no constraint) [m / yr]')) 54 s += '{}\n'.format(fielddisplay(self, 'spcvz', 'z - axis velocity constraint (NaN means no constraint) [m / yr]')) 55 s += '{}\n'.format(fielddisplay(self, 'icefront', 'segments on ice front list (last column 0: Air, 1: Water, 2: Ice')) 56 s = "%s\n%s" % (s, '\n Rift options:') 57 s += '{}\n'.format(fielddisplay(self, 'rift_penalty_threshold', 'threshold for instability of mechanical constraints')) 58 s += '{}\n'.format(fielddisplay(self, 'rift_penalty_lock', 'number of iterations before rift penalties are locked')) 59 s += ' Penalty options:\n' 60 s += '{}\n'.format(fielddisplay(self, 'penalty_factor', 'offset used by penalties: penalty = Kmax * 1.0**offset')) 61 s += '{}\n'.format(fielddisplay(self, 'vertex_pairing', 'pairs of vertices that are penalized')) 62 s += ' Other:\n' 63 s += '{}\n'.format(fielddisplay(self, 'shelf_dampening', 'use dampening for floating ice ? Only for FS model')) 64 s += '{}\n'.format(fielddisplay(self, 'FSreconditioning', 'multiplier for incompressibility equation. Only for FS model')) 65 s += '{}\n'.format(fielddisplay(self, 'referential', 'local referential')) 66 s += '{}\n'.format(fielddisplay(self, 'loadingforce', 'loading force applied on each point [N / m^3]')) 67 s += '{}\n'.format(fielddisplay(self, 'requested_outputs', 'additional outputs requested')) 68 return s 74 69 #}}} 75 70 … … 103 98 #output default: 104 99 self.requested_outputs = ['default'] 105 106 100 return self 107 101 #}}} … … 113 107 list = ['Vx', 'Vy', 'Vel', 'Pressure'] 114 108 return list 115 116 109 #}}} 117 110 118 111 def checkconsistency(self, md, solution, analyses): # {{{ 119 # Early return112 # Early return 120 113 if 'StressbalanceAnalysis' not in analyses: 114 return md 115 if solution == 'TransientSolution' and not md.transient.isstressbalance: 121 116 return md 122 117 … … 159 154 if np.any(np.logical_not(np.isnan(md.stressbalance.referential[pos, :]))): 160 155 md.checkmessage("no referential should be specified for basal vertices of grounded ice") 161 162 156 return md 163 157 # }}} … … 183 177 WriteData(fid, prefix, 'object', self, 'class', 'stressbalance', 'fieldname', 'rift_penalty_threshold', 'format', 'Integer') 184 178 WriteData(fid, prefix, 'object', self, 'class', 'stressbalance', 'fieldname', 'referential', 'format', 'DoubleMat', 'mattype', 1) 185 186 179 if isinstance(self.loadingforce, (list, tuple, np.ndarray)) and np.size(self.loadingforce, 1) == 3: 187 180 WriteData(fid, prefix, 'data', self.loadingforce[:, 0], 'format', 'DoubleMat', 'mattype', 1, 'name', 'md.stressbalance.loadingforcex') 188 181 WriteData(fid, prefix, 'data', self.loadingforce[:, 1], 'format', 'DoubleMat', 'mattype', 1, 'name', 'md.stressbalance.loadingforcey') 189 182 WriteData(fid, prefix, 'data', self.loadingforce[:, 2], 'format', 'DoubleMat', 'mattype', 1, 'name', 'md.stressbalance.loadingforcez') 190 191 #process requested outputs 183 # Process requested outputs 192 184 outputs = self.requested_outputs 193 185 indices = [i for i, x in enumerate(outputs) if x == 'default'] -
issm/trunk-jpl/src/m/classes/surfaceload.py
r25499 r25688 31 31 s += '{}\n'.format(fielddisplay(self, 'waterheightchange', 'water height change: water height equivalent [mWater/yr]')) 32 32 s += '{}\n'.format(fielddisplay(self, 'other', 'other loads (sediments) [kg/m^2/yr]')) 33 34 33 return s 35 34 #}}} 36 35 37 36 def setdefaultparameters(self): # {{{ 38 return 37 return self 39 38 #}}} 40 39 41 40 def checkconsistency(self, md, solution, analyses): # {{{ 42 if ('SealevelriseAnalysis' not in analyses) or (solution == 'TransientSolution' and md.transient.isslr == 0):41 if ('SealevelriseAnalysis' not in analyses) or (solution == 'TransientSolution' and not md.transient.isslr): 43 42 return md 44 45 43 if len(self.icethicknesschange): 46 44 md = checkfield(md,'fieldname', 'solidearth.surfaceload.icethicknesschange', 'timeseries', 1, 'NaN', 1, 'Inf', 1) 47 48 45 if len(self.waterheightchange): 49 46 md = checkfield(md,'fieldname', 'solidearth.surfaceload.waterheightchange', 'timeseries', 1, 'NaN', 1, 'Inf', 1) 50 51 47 if len(self.other): 52 48 md = checkfield(md,'fieldname', 'solidearth.surfaceload.other', 'timeseries', 1, 'NaN', 1, 'Inf', 1) 53 54 49 return md 55 50 #}}} … … 58 53 if len(self.icethicknesschange) == 0: 59 54 self.icethicknesschange = np.zeros((md.mesh.numberofelements + 1, )) 60 61 55 if len(self.waterheightchange) == 0: 62 56 self.waterheightchange = np.zeros((md.mesh.numberofelements + 1, )) 63 64 57 if len(self.other) == 0: 65 58 self.other = np.zeros((md.mesh.numberofelements + 1, )) 66 67 59 WriteData(fid, prefix, 'object', self, 'fieldname', 'icethicknesschange', 'name', 'md.solidearth.surfaceload.icethicknesschange', 'format', 'DoubleMat', 'mattype', 2, 'timeserieslength', md.mesh.numberofelements + 1, 'yts', md.constants.yts) 68 60 WriteData(fid, prefix, 'object', self, 'fieldname', 'waterheightchange', 'name', 'md.solidearth.surfaceload.waterheightchange', 'format', 'DoubleMat', 'mattype', 2, 'timeserieslength', md.mesh.numberofelements + 1, 'yts', md.constants.yts) -
issm/trunk-jpl/src/m/classes/taoinversion.py
r24213 r25688 1 1 import numpy as np 2 from project3d import project3d 3 from WriteData import WriteData 2 4 3 from checkfield import checkfield 5 4 from IssmConfig import IssmConfig 6 5 from marshallcostfunctions import marshallcostfunctions 6 from project3d import project3d 7 7 from supportedcontrols import * 8 8 from supportedcostfunctions import * 9 from WriteData import WriteData 9 10 10 11 11 class taoinversion(object): 12 class taoinversion(object): #{{{ 13 """TAOINVERSION class definition 14 15 Usage: 16 inversion = taoinversion() 17 """ 18 12 19 def __init__(self): 13 20 self.iscontrol = 0 14 21 self.incomplete_adjoint = 0 15 self.control_parameters = float('NaN')22 self.control_parameters = np.nan 16 23 self.maxsteps = 0 17 24 self.maxiter = 0 … … 22 29 self.gttol = 0 23 30 self.algorithm = '' 24 self.cost_functions = float('NaN') 25 self.cost_functions_coefficients = float('NaN') 26 self.min_parameters = float('NaN') 27 self.max_parameters = float('NaN') 28 self.vx_obs = float('NaN') 29 self.vy_obs = float('NaN') 30 self.vz_obs = float('NaN') 31 self.vel_obs = float('NaN') 32 self.thickness_obs = float('NaN') 33 self.surface_obs = float('NaN') 31 self.cost_functions = np.nan 32 self.cost_functions_coefficients = np.nan 33 self.min_parameters = np.nan 34 self.max_parameters = np.nan 35 self.vx_obs = np.nan 36 self.vy_obs = np.nan 37 self.vz_obs = np.nan 38 self.vel_obs = np.nan 39 self.thickness_obs = np.nan 40 self.surface_obs = np.nan 41 34 42 self.setdefaultparameters() 43 #}}} 35 44 36 45 def __repr__(self): 37 s tring = ' taoinversion parameters:'38 s tring = "%s\n%s" % (string,fieldstring(self, 'iscontrol', 'is inversion activated?'))39 s tring = "%s\n%s" % (string,fieldstring(self, 'mantle_viscosity', 'mantle viscosity constraints (NaN means no constraint) (Pa s)'))40 s tring = "%s\n%s" % (string,fieldstring(self, 'lithosphere_thickness', 'lithosphere thickness constraints (NaN means no constraint) (m)'))41 s tring = "%s\n%s" % (string,fieldstring(self, 'cross_section_shape', "1: square-edged, 2: elliptical - edged surface"))42 s tring = "%s\n%s" % (string,fieldstring(self, 'incomplete_adjoint', '1: linear viscosity, 0: non - linear viscosity'))43 s tring = "%s\n%s" % (string,fieldstring(self, 'control_parameters', 'ex: {''FrictionCoefficient''}, or {''MaterialsRheologyBbar''}'))44 s tring = "%s\n%s" % (string,fieldstring(self, 'maxsteps', 'maximum number of iterations (gradient computation)'))45 s tring = "%s\n%s" % (string,fieldstring(self, 'maxiter', 'maximum number of Function evaluation (forward run)'))46 s tring = "%s\n%s" % (string,fieldstring(self, 'fatol', 'convergence criterion: f(X) - f(X * ) (X: current iteration, X * : "true" solution, f: cost function)'))47 s tring = "%s\n%s" % (string,fieldstring(self, 'frtol', 'convergence criterion: |f(X) - f(X * )| / |f(X * )|'))48 s tring = "%s\n%s" % (string,fieldstring(self, 'gatol', 'convergence criterion: ||g(X)|| (g: gradient of the cost function)'))49 s tring = "%s\n%s" % (string,fieldstring(self, 'grtol', 'convergence criterion: ||g(X)|| / |f(X)|'))50 s tring = "%s\n%s" % (string,fieldstring(self, 'gttol', 'convergence criterion: ||g(X)|| / ||g(X0)|| (g(X0): gradient at initial guess X0)'))51 s tring = "%s\n%s" % (string,fieldstring(self, 'algorithm', 'minimization algorithm: ''tao_blmvm'', ''tao_cg'', ''tao_lmvm'''))52 s tring = "%s\n%s" % (string,fieldstring(self, 'cost_functions', 'indicate the type of response for each optimization step'))53 s tring = "%s\n%s" % (string,fieldstring(self, 'cost_functions_coefficients', 'cost_functions_coefficients applied to the misfit of each vertex and for each control_parameter'))54 s tring = "%s\n%s" % (string,fieldstring(self, 'min_parameters', 'absolute minimum acceptable value of the inversed parameter on each vertex'))55 s tring = "%s\n%s" % (string,fieldstring(self, 'max_parameters', 'absolute maximum acceptable value of the inversed parameter on each vertex'))56 s tring = "%s\n%s" % (string,fieldstring(self, 'vx_obs', 'observed velocity x component [m / yr]'))57 s tring = "%s\n%s" % (string,fieldstring(self, 'vy_obs', 'observed velocity y component [m / yr]'))58 s tring = "%s\n%s" % (string,fieldstring(self, 'vel_obs', 'observed velocity magnitude [m / yr]'))59 s tring = "%s\n%s" % (string,fieldstring(self, 'thickness_obs', 'observed thickness [m]'))60 s tring = "%s\n%s" % (string,fieldstring(self, 'surface_obs', 'observed surface elevation [m]'))61 s tring = "%s\n%s" % (string,'Available cost functions:')62 s tring = "%s\n%s" % (string,' 101: SurfaceAbsVelMisfit')63 s tring = "%s\n%s" % (string,' 102: SurfaceRelVelMisfit')64 s tring = "%s\n%s" % (string,' 103: SurfaceLogVelMisfit')65 s tring = "%s\n%s" % (string,' 104: SurfaceLogVxVyMisfit')66 s tring = "%s\n%s" % (string,' 105: SurfaceAverageVelMisfit')67 s tring = "%s\n%s" % (string,' 201: ThicknessAbsMisfit')68 s tring = "%s\n%s" % (string,' 501: DragCoefficientAbsGradient')69 s tring = "%s\n%s" % (string,' 502: RheologyBbarAbsGradient')70 s tring = "%s\n%s" % (string,' 503: ThicknessAbsGradient')71 return s tring46 s = ' taoinversion parameters:\n' 47 s += '{}'.format(fieldstring(self, 'iscontrol', 'is inversion activated?')) 48 s += '{}'.format(fieldstring(self, 'mantle_viscosity', 'mantle viscosity constraints (NaN means no constraint) (Pa s)')) 49 s += '{}'.format(fieldstring(self, 'lithosphere_thickness', 'lithosphere thickness constraints (NaN means no constraint) (m)')) 50 s += '{}'.format(fieldstring(self, 'cross_section_shape', "1: square-edged, 2: elliptical - edged surface")) 51 s += '{}'.format(fieldstring(self, 'incomplete_adjoint', '1: linear viscosity, 0: non - linear viscosity')) 52 s += '{}'.format(fieldstring(self, 'control_parameters', 'ex: {''FrictionCoefficient''}, or {''MaterialsRheologyBbar''}')) 53 s += '{}'.format(fieldstring(self, 'maxsteps', 'maximum number of iterations (gradient computation)')) 54 s += '{}'.format(fieldstring(self, 'maxiter', 'maximum number of Function evaluation (forward run)')) 55 s += '{}'.format(fieldstring(self, 'fatol', 'convergence criterion: f(X) - f(X * ) (X: current iteration, X * : "true" solution, f: cost function)')) 56 s += '{}'.format(fieldstring(self, 'frtol', 'convergence criterion: |f(X) - f(X * )| / |f(X * )|')) 57 s += '{}'.format(fieldstring(self, 'gatol', 'convergence criterion: ||g(X)|| (g: gradient of the cost function)')) 58 s += '{}'.format(fieldstring(self, 'grtol', 'convergence criterion: ||g(X)|| / |f(X)|')) 59 s += '{}'.format(fieldstring(self, 'gttol', 'convergence criterion: ||g(X)|| / ||g(X0)|| (g(X0): gradient at initial guess X0)')) 60 s += '{}'.format(fieldstring(self, 'algorithm', 'minimization algorithm: ''tao_blmvm'', ''tao_cg'', ''tao_lmvm''')) 61 s += '{}'.format(fieldstring(self, 'cost_functions', 'indicate the type of response for each optimization step')) 62 s += '{}'.format(fieldstring(self, 'cost_functions_coefficients', 'cost_functions_coefficients applied to the misfit of each vertex and for each control_parameter')) 63 s += '{}'.format(fieldstring(self, 'min_parameters', 'absolute minimum acceptable value of the inversed parameter on each vertex')) 64 s += '{}'.format(fieldstring(self, 'max_parameters', 'absolute maximum acceptable value of the inversed parameter on each vertex')) 65 s += '{}'.format(fieldstring(self, 'vx_obs', 'observed velocity x component [m / yr]')) 66 s += '{}'.format(fieldstring(self, 'vy_obs', 'observed velocity y component [m / yr]')) 67 s += '{}'.format(fieldstring(self, 'vel_obs', 'observed velocity magnitude [m / yr]')) 68 s += '{}'.format(fieldstring(self, 'thickness_obs', 'observed thickness [m]')) 69 s += '{}'.format(fieldstring(self, 'surface_obs', 'observed surface elevation [m]')) 70 s += '{}'.format('Available cost functions:') 71 s += '{}'.format(' 101: SurfaceAbsVelMisfit') 72 s += '{}'.format(' 102: SurfaceRelVelMisfit') 73 s += '{}'.format(' 103: SurfaceLogVelMisfit') 74 s += '{}'.format(' 104: SurfaceLogVxVyMisfit') 75 s += '{}'.format(' 105: SurfaceAverageVelMisfit') 76 s += '{}'.format(' 201: ThicknessAbsMisfit') 77 s += '{}'.format(' 501: DragCoefficientAbsGradient') 78 s += '{}'.format(' 502: RheologyBbarAbsGradient') 79 s += '{}'.format(' 503: ThicknessAbsGradient') 80 return s 72 81 73 82 def setdefaultparameters(self): -
issm/trunk-jpl/src/m/classes/thermal.py
r24567 r25688 1 1 import numpy as np 2 3 from checkfield import checkfield 4 from fielddisplay import fielddisplay 2 5 from project3d import project3d 3 from fielddisplay import fielddisplay4 from checkfield import checkfield5 6 from WriteData import WriteData 6 7 7 8 8 9 class thermal(object): 9 """ 10 THERMAL class definition 10 """THERMAL class definition 11 11 12 12 Usage: … … 28 28 self.fe = 'P1' 29 29 self.requested_outputs = [] 30 31 #set defaults32 30 self.setdefaultparameters() 33 34 31 #}}} 35 32 36 33 def __repr__(self): # {{{ 37 s tring = ' Thermal solution parameters:'38 s tring = "%s\n%s" % (string,fielddisplay(self, 'spctemperature', 'temperature constraints (NaN means no constraint) [K]'))39 s tring = "%s\n%s" % (string,fielddisplay(self, 'stabilization', '0: no, 1: artificial_diffusivity, 2: SUPG'))40 s tring = "%s\n%s" % (string,fielddisplay(self, 'maxiter', 'maximum number of non linear iterations'))41 s tring = "%s\n%s" % (string,fielddisplay(self, 'reltol', 'relative tolerance criterion'))42 s tring = "%s\n%s" % (string,fielddisplay(self, 'penalty_lock', 'stabilize unstable thermal constraints that keep zigzagging after n iteration (default is 0, no stabilization)'))43 s tring = "%s\n%s" % (string,fielddisplay(self, 'penalty_threshold', 'threshold to declare convergence of thermal solution (default is 0)'))44 s tring = "%s\n%s" % (string,fielddisplay(self, 'isenthalpy', 'use an enthalpy formulation to include temperate ice (default is 0)'))45 s tring = "%s\n%s" % (string,fielddisplay(self, 'isdynamicbasalspc', 'enable dynamic setting of basal forcing. required for enthalpy formulation (default is 0)'))46 s tring = "%s\n%s" % (string,fielddisplay(self, 'isdrainicecolumn', 'wether waterfraction drainage is enabled for enthalpy formulation (default is 1)'))47 s tring = "%s\n%s" % (string,fielddisplay(self, 'watercolumn_upperlimit', 'upper limit of basal watercolumn for enthalpy formulation (default is 1000m)'))48 s tring = "%s\n%s" % (string,fielddisplay(self, 'requested_outputs', 'additional outputs requested'))49 return s tring34 s = ' Thermal solution parameters:\n' 35 s += '{}\n'.format(fielddisplay(self, 'spctemperature', 'temperature constraints (NaN means no constraint) [K]')) 36 s += '{}\n'.format(fielddisplay(self, 'stabilization', '0: no, 1: artificial_diffusivity, 2: SUPG')) 37 s += '{}\n'.format(fielddisplay(self, 'maxiter', 'maximum number of non linear iterations')) 38 s += '{}\n'.format(fielddisplay(self, 'reltol', 'relative tolerance criterion')) 39 s += '{}\n'.format(fielddisplay(self, 'penalty_lock', 'stabilize unstable thermal constraints that keep zigzagging after n iteration (default is 0, no stabilization)')) 40 s += '{}\n'.format(fielddisplay(self, 'penalty_threshold', 'threshold to declare convergence of thermal solution (default is 0)')) 41 s += '{}\n'.format(fielddisplay(self, 'isenthalpy', 'use an enthalpy formulation to include temperate ice (default is 0)')) 42 s += '{}\n'.format(fielddisplay(self, 'isdynamicbasalspc', 'enable dynamic setting of basal forcing. required for enthalpy formulation (default is 0)')) 43 s += '{}\n'.format(fielddisplay(self, 'isdrainicecolumn', 'wether waterfraction drainage is enabled for enthalpy formulation (default is 1)')) 44 s += '{}\n'.format(fielddisplay(self, 'watercolumn_upperlimit', 'upper limit of basal watercolumn for enthalpy formulation (default is 1000m)')) 45 s += '{}\n'.format(fielddisplay(self, 'requested_outputs', 'additional outputs requested')) 46 return s 50 47 #}}} 51 48 … … 64 61 else: 65 62 return ['Temperature', 'BasalforcingsGroundediceMeltingRate'] 66 67 63 #}}} 68 64 … … 91 87 self.requested_outputs = ['default'] 92 88 return self 93 94 89 #}}} 95 90 96 91 def checkconsistency(self, md, solution, analyses): # {{{ 97 # Early return92 # Early return 98 93 if ('ThermalAnalysis' not in analyses and 'EnthalpyAnalysis' not in analyses) or (solution == 'TransientSolution' and not md.transient.isthermal): 99 94 return md 100 101 95 md = checkfield(md, 'fieldname', 'thermal.stabilization', 'numel', [1], 'values', [0, 1, 2]) 102 96 md = checkfield(md, 'fieldname', 'thermal.spctemperature', 'Inf', 1, 'timeseries', 1) 103 97 md = checkfield(md, 'fieldname', 'thermal.requested_outputs', 'stringrow', 1) 104 105 98 if 'EnthalpyAnalysis' in analyses and md.thermal.isenthalpy and md.mesh.dimension() == 3: 106 99 md = checkfield(md, 'fieldname', 'thermal.isdrainicecolumn', 'numel', [1], 'values', [0, 1]) … … 123 116 md.checkmessage("for a steadystate computation, thermal.reltol (relative convergence criterion) must be defined!") 124 117 md = checkfield(md, 'fieldname', 'thermal.reltol', '>', 0., 'message', "reltol must be larger than zero") 125 126 118 return md 127 119 # }}} -
issm/trunk-jpl/src/m/classes/transient.py
r24990 r25688 1 from checkfield import checkfield 1 2 from fielddisplay import fielddisplay 2 from checkfield import checkfield3 3 from WriteData import WriteData 4 4 5 5 6 6 class transient(object): 7 """ 8 TRANSIENT class definition 7 """TRANSIENT class definition 9 8 10 11 9 Usage: 10 transient = transient() 12 11 """ 13 12 14 13 def __init__(self): # {{{ 15 self.issmb = False16 self.ismasstransport = False17 self.isstressbalance = False18 self.isthermal = False19 self.isgroundingline = False20 self.isgia = False21 self.isesa = False22 self.isdamageevolution = False23 self.ismovingfront = False24 self.ishydrology = False25 self.isslr = False26 self.iscoupler = False14 self.issmb = 0 15 self.ismasstransport = 0 16 self.isstressbalance = 0 17 self.isthermal = 0 18 self.isgroundingline = 0 19 self.isgia = 0 20 self.isesa = 0 21 self.isdamageevolution = 0 22 self.ismovingfront = 0 23 self.ishydrology = 0 24 self.isslr = 0 25 self.iscoupler = 0 27 26 self.amr_frequency = 0 28 self.isoceancoupling = False27 self.isoceancoupling = 0 29 28 self.requested_outputs = [] 30 29 31 #set defaults32 30 self.setdefaultparameters() 31 #}}} 33 32 34 #}}}35 33 def __repr__(self): # {{{ 36 s tring = ' transient solution parameters:'37 s tring = "%s\n%s" % (string,fielddisplay(self, 'issmb', 'indicates if a surface mass balance solution is used in the transient'))38 s tring = "%s\n%s" % (string,fielddisplay(self, 'ismasstransport', 'indicates if a masstransport solution is used in the transient'))39 s tring = "%s\n%s" % (string,fielddisplay(self, 'isstressbalance', 'indicates if a stressbalance solution is used in the transient'))40 s tring = "%s\n%s" % (string,fielddisplay(self, 'isthermal', 'indicates if a thermal solution is used in the transient'))41 s tring = "%s\n%s" % (string,fielddisplay(self, 'isgroundingline', 'indicates if a groundingline migration is used in the transient'))42 s tring = "%s\n%s" % (string,fielddisplay(self, 'isgia', 'indicates if a postglacial rebound is used in the transient'))43 s tring = "%s\n%s" % (string,fielddisplay(self, 'isesa', 'indicates whether an elastic adjustment model is used in the transient'))44 s tring = "%s\n%s" % (string,fielddisplay(self, 'isdamageevolution', 'indicates whether damage evolution is used in the transient'))45 s tring = "%s\n%s" % (string,fielddisplay(self, 'ismovingfront', 'indicates whether a moving front capability is used in the transient'))46 s tring = "%s\n%s" % (string,fielddisplay(self, 'ishydrology', 'indicates whether an hydrology model is used'))47 s tring = "%s\n%s" % (string,fielddisplay(self, 'isslr', 'indicates if a sea level rise solution is used in the transient'))48 s tring = "%s\n%s" % (string,fielddisplay(self, 'isoceancoupling', 'indicates whether coupling with an ocean model is used in the transient'))49 s tring = "%s\n%s" % (string,fielddisplay(self, 'iscoupler', 'indicates whether different models are being run with need for coupling'))50 s tring = "%s\n%s" % (string,fielddisplay(self, 'amr_frequency', 'frequency at which mesh is refined in simulations with multiple time_steps'))51 s tring = "%s\n%s" % (string,fielddisplay(self, 'requested_outputs', 'list of additional outputs requested'))52 return s tring34 s = ' transient solution parameters:\n' 35 s += '{}\n'.format(fielddisplay(self, 'issmb', 'indicates if a surface mass balance solution is used in the transient')) 36 s += '{}\n'.format(fielddisplay(self, 'ismasstransport', 'indicates if a masstransport solution is used in the transient')) 37 s += '{}\n'.format(fielddisplay(self, 'isstressbalance', 'indicates if a stressbalance solution is used in the transient')) 38 s += '{}\n'.format(fielddisplay(self, 'isthermal', 'indicates if a thermal solution is used in the transient')) 39 s += '{}\n'.format(fielddisplay(self, 'isgroundingline', 'indicates if a groundingline migration is used in the transient')) 40 s += '{}\n'.format(fielddisplay(self, 'isgia', 'indicates if a postglacial rebound is used in the transient')) 41 s += '{}\n'.format(fielddisplay(self, 'isesa', 'indicates whether an elastic adjustment model is used in the transient')) 42 s += '{}\n'.format(fielddisplay(self, 'isdamageevolution', 'indicates whether damage evolution is used in the transient')) 43 s += '{}\n'.format(fielddisplay(self, 'ismovingfront', 'indicates whether a moving front capability is used in the transient')) 44 s += '{}\n'.format(fielddisplay(self, 'ishydrology', 'indicates whether an hydrology model is used')) 45 s += '{}\n'.format(fielddisplay(self, 'isslr', 'indicates if a sea level rise solution is used in the transient')) 46 s += '{}\n'.format(fielddisplay(self, 'isoceancoupling', 'indicates whether coupling with an ocean model is used in the transient')) 47 s += '{}\n'.format(fielddisplay(self, 'iscoupler', 'indicates whether different models are being run with need for coupling')) 48 s += '{}\n'.format(fielddisplay(self, 'amr_frequency', 'frequency at which mesh is refined in simulations with multiple time_steps')) 49 s += '{}\n'.format(fielddisplay(self, 'requested_outputs', 'list of additional outputs requested')) 50 return s 53 51 #}}} 54 52 55 53 def defaultoutputs(self, md): # {{{ 56 57 54 if self.issmb: 58 55 return ['SmbMassBalance'] 59 56 else: 60 57 return [] 61 62 58 #}}} 63 59 64 60 def deactivateall(self): #{{{ 65 self.issmb = False66 self.ismasstransport = False67 self.isstressbalance = False68 self.isthermal = False69 self.isgroundingline = False70 self.isgia = False71 self.isesa = False72 self.isdamageevolution = False73 self.ismovingfront = False74 self.ishydrology = False75 self.isslr = False76 self.isoceancoupling = False77 self.iscoupler = False61 self.issmb = 0 62 self.ismasstransport = 0 63 self.isstressbalance = 0 64 self.isthermal = 0 65 self.isgroundingline = 0 66 self.isgia = 0 67 self.isesa = 0 68 self.isdamageevolution = 0 69 self.ismovingfront = 0 70 self.ishydrology = 0 71 self.isslr = 0 72 self.isoceancoupling = 0 73 self.iscoupler = 0 78 74 self.amr_frequency = 0 79 75 80 #default output76 # Default output 81 77 self.requested_outputs = [] 82 78 return self … … 85 81 def setdefaultparameters(self): # {{{ 86 82 #full analysis: Stressbalance, Masstransport and Thermal but no groundingline migration for now 87 self.issmb = True88 self.ismasstransport = True89 self.isstressbalance = True90 self.isthermal = True91 self.isgroundingline = False92 self.isgia = False93 self.isesa = False94 self.isdamageevolution = False95 self.ismovingfront = False96 self.ishydrology = False97 self.isslr = False98 self.isoceancoupling = False99 self.iscoupler = False83 self.issmb = 1 84 self.ismasstransport = 1 85 self.isstressbalance = 1 86 self.isthermal = 1 87 self.isgroundingline = 0 88 self.isgia = 0 89 self.isesa = 0 90 self.isdamageevolution = 0 91 self.ismovingfront = 0 92 self.ishydrology = 0 93 self.isslr = 0 94 self.isoceancoupling = 0 95 self.iscoupler = 0 100 96 self.amr_frequency = 0 101 97 102 #default output98 # Default output 103 99 self.requested_outputs = ['default'] 104 100 return self … … 124 120 md = checkfield(md, 'fieldname', 'transient.iscoupler', 'numel', [1], 'values', [0, 1]) 125 121 md = checkfield(md, 'fieldname', 'transient.amr_frequency', 'numel', [1], '>=', 0, 'NaN', 1, 'Inf', 1) 126 md = checkfield(md, 'fieldname', 'transient.requested_outputs', 'stringrow', 1)127 122 128 if (solution != 'TransientSolution') and (md.transient.iscoupling):123 if solution != 'TransientSolution' and md.transient.iscoupling: 129 124 md.checkmessage("Coupling with ocean can only be done in transient simulations!") 130 if (md.transient.isdamageevolution and not hasattr(md.materials, 'matdamageice')):125 if md.transient.isdamageevolution and not hasattr(md.materials, 'matdamageice'): 131 126 md.checkmessage("requesting damage evolution but md.materials is not of class matdamageice") 132 133 127 return md 134 128 # }}} … … 150 144 WriteData(fid, prefix, 'object', self, 'fieldname', 'amr_frequency', 'format', 'Integer') 151 145 152 #process requested outputs146 # Process requested outputs 153 147 outputs = self.requested_outputs 154 148 indices = [i for i, x in enumerate(outputs) if x == 'default'] -
issm/trunk-jpl/src/m/miscellaneous/pretty_print.m
r25455 r25688 15 15 % - Add an argument that allows the user to specify the number of values that 16 16 % they would like to display from the head and tail of each dimension of 17 % 'data'. 17 % 'data' (default is 3 from each end). 18 % - Add an argument that allows the user to designate the number of 19 % significant figures to print for each floating point value (default is 8). 18 20 19 21 if ndims(data)==1 20 22 if length(data)>6 21 disp(sprintf('[%d %d %d ... %d %d %d]',data(1),data(2),data(3),data(end-2),data(end-1),data(end)));23 output=sprintf('[%.8f %.8f %.8f ... %.8f %.8f %.8f]',data(1),data(2),data(3),data(end-2),data(end-1),data(end)); 22 24 else 23 disp(data);25 output=sprintf('%.8f',data); 24 26 end 25 27 elseif ndims(data)==2 26 28 shape=size(data); 27 29 if shape(1)>6 28 % if shape(2)==129 % disp('NOTE: Single column printed as row!');30 % disp(sprintf('[%d %d %d ... %d %d %d]',data(1,1),data(2,1),data(3,1),data(end-2,1),data(end-1,1),data(end,1)));31 % else32 30 if shape(2)>6 33 disp('['); 34 disp(sprintf('[%d %d %d ... %d %d %d]',data(1,1),data(1,2),data(1,3),data(1,end-2),data(1,end-1),data(1,end))); 35 disp(sprintf('[%d %d %d ... %d %d %d]',data(2,1),data(2,2),data(2,3),data(2,end-2),data(2,end-1),data(2,end))); 36 disp(sprintf('[%d %d %d ... %d %d %d]',data(3,1),data(3,2),data(3,3),data(3,end-2),data(3,end-1),data(3,end))); 37 disp('...'); 38 disp(sprintf('[%d %d %d ... %d %d %d]',data(end-2,1),data(end-2,2),data(end-2,3),data(end-2,end-2),data(end-2,end-1),data(end-2,end))); 39 disp(sprintf('[%d %d %d ... %d %d %d]',data(end-1,1),data(end-1,2),data(end-1,3),data(end-1,end-2),data(end-1,end-1),data(end-1,end))); 40 disp(sprintf('[%d %d %d ... %d %d %d]',data(end,1),data(end,2),data(end,3),data(end,end-2),data(end,end-1),data(end,end))); 41 disp(sprintf(']\n')); 31 output=sprintf('[[%.8f %.8f %.8f ... %.8f %.8f %.8f]\n',data(1,1),data(1,2),data(1,3),data(1,end-2),data(1,end-1),data(1,end)); 32 output=sprintf('%s [%.8f %.8f %.8f ... %.8f %.8f %.8f]\n',data(2,1),data(2,2),data(2,3),data(2,end-2),data(2,end-1),data(2,end)); 33 output=sprintf('%s [%.8f %.8f %.8f ... %.8f %.8f %.8f]\n',data(3,1),data(3,2),data(3,3),data(3,end-2),data(3,end-1),data(3,end)); 34 output=sprintf('%s ...\n',output); 35 output=sprintf('%s [%.8f %.8f %.8f ... %.8f %.8f %.8f]\n',data(end-2,1),data(end-2,2),data(end-2,3),data(end-2,end-2),data(end-2,end-1),data(end-2,end)); 36 output=sprintf('%s [%.8f %.8f %.8f ... %.8f %.8f %.8f]\n',data(end-1,1),data(end-1,2),data(end-1,3),data(end-1,end-2),data(end-1,end-1),data(end-1,end)); 37 output=sprintf('%s [%.8f %.8f %.8f ... %.8f %.8f %.8f]]',data(end,1),data(end,2),data(end,3),data(end,end-2),data(end,end-1),data(end,end)); 42 38 else 43 disp('['); 44 disp(data(1,:)); 45 disp(data(2,:)); 46 disp(data(3,:)); 47 disp('...'); 48 disp(data(end-2,:)); 49 disp(data(end-1,:)); 50 disp(data(end,:)); 51 disp(sprintf(']\n')); 39 output=sprintf('[[%.8f]\n',data(1,:)); 40 output=sprintf('%s [%.8f]\n',output,data(2,:)); 41 output=sprintf('%s [%.8f]\n',output,data(3,:)); 42 output=sprintf('%s ...\n',output); 43 output=sprintf('%s [%.8f]\n',output,data(end-2,:)); 44 output=sprintf('%s [%.8f]\n',output,data(end-1,:)); 45 output=sprintf('%s [%.8f]]',output,data(end,:)); 52 46 end 53 47 else 54 % if shape(2)==155 % data=transpose(data)56 % sprintf('% NOTE: Single column printed as row!');57 % % Get shape of transposed structure58 % shape=size(data);59 % if shape(2)>660 % disp(sprintf('[%d %d %d ... %d %d %d]',data(1,1),data(2,1),data(3,1),data(end-2,1),data(end-1,1),data(end,1)));61 % else62 % disp(data);63 % end64 % else65 48 if shape(2)>6 66 disp('[');67 49 for i=1:shape(1) 68 disp(sprintf('[%d %d %d ... %d %d %d]',data(i,1),data(i,2),data(i,3),data(i,end-2),data(i,end-1),data(i,end))); 50 if i==1 51 output='['; 52 else 53 output=sprintf('%s ',output); 54 end 55 56 output=sprintf('%s[%.8f %.8f %.8f ... %.8f %.8f %.8f]',output,data(i,1),data(i,2),data(i,3),data(i,end-2),data(i,end-1),data(i,end)); 57 58 if i==shape(1) 59 output=sprintf('%s]',output); 60 end 69 61 end 70 disp(sprintf(']\n'));71 62 else 72 disp(data);63 output=sprintf('%.8f',data); 73 64 end 74 65 end 75 66 else 76 disp(data);67 output=sprintf('%.8f',data); 77 68 end 69 70 disp(output); -
issm/trunk-jpl/src/m/qmu/dakota_out_parse.m
r24759 r25688 90 90 [ntokens,tokens]=fltokens(fline); 91 91 method=tokens{1}{1}; 92 display(sprintf('Dakota method = ''%s''.',method));92 display(sprintf('Dakota method = ''%s''.',method)); 93 93 elseif strcmp(tokens{1}{1}(7),'N') 94 94 [fline]=findline(fidi,'methodName = '); 95 95 [ntokens,tokens]=fltokens(fline); 96 96 method=tokens{1}{3}; 97 display(sprintf('Dakota methodName =''%s''.',method));97 display(sprintf('Dakota methodName = ''%s''.',method)); 98 98 end 99 99 end -
issm/trunk-jpl/src/m/qmu/dakota_out_parse.py
r24213 r25688 87 87 [ntokens, tokens] = fltokens(fline) 88 88 method = tokens[0].strip() 89 print('Dakota method = \'' + method + '\'.')89 print('Dakota method = \'' + method + '\'.') 90 90 elif fline[6] in ['N', 'n']: 91 91 fline = findline(fidi, 'methodName = ') 92 92 [ntokens, tokens] = fltokens(fline) 93 93 method = tokens[2].strip() 94 print('Dakota methodName = "' + method + '".')94 print('Dakota methodName = \'' + method + '\'.') 95 95 96 96 # loop through the file to find the function evaluation summary -
issm/trunk-jpl/src/m/qmu/postqmu.py
r25685 r25688 1 from copy import deepcopy 1 2 from os import getpid, stat 2 3 from os.path import isfile … … 5 6 from dakota_out_parse import * 6 7 from helpers import * 7 from loadresultsfromdisk import * 8 import loadresultsfromdisk as loadresults 8 9 9 10 … … 48 49 if md.qmu.method.method == 'nond_sampling': 49 50 dakotaresults.modelresults = [] 50 md2 = copy.deepcopy(md)51 md2 = deepcopy(md) 51 52 md2.qmu.isdakota = 0 52 53 for i in range(md2.qmu.method.params.samples): 53 print('reading qmu file {}.outbin.{}'.format(md2.miscellaneous.name, i)) 54 md2 = loadresultsfromdisk(md2, '{}.outbin.{}'.format(md2.miscellaneous.name, i)) 54 outbin_name = '{}.outbin.{}'.format(md2.miscellaneous.name, (i + 1)) 55 print('reading qmu file {}'.format(outbin_name)) 56 md2 = loadresults.loadresultsfromdisk(md2, outbin_name) 55 57 dakotaresults.modelresults.append(md2.results) 56 58 57 59 if md.qmu.statistics.method[0]['name'] != 'None': 58 60 md.qmu.isdakota = 0 59 md = loadresults fromdisk(md, [md.miscellaneous.name,'.stats'])61 md = loadresults.loadresultsfromdisk(md, '{}.stats'.format(md.miscellaneous.name)) 60 62 md.qmu.isdakota = 1 61 63 -
issm/trunk-jpl/src/m/qmu/preqmu.m
r25328 r25688 101 101 variablepartitions{end+1}=fieldvariable.partition; 102 102 variablepartitions_npart(end+1)=qmupart2npart(fieldvariable.partition); 103 if is field(struct(fieldvariable),'nsteps'),103 if isprop(fieldvariable,'nsteps'), 104 104 variablepartitions_nt(end+1)=fieldvariable.nsteps; 105 105 else -
issm/trunk-jpl/src/m/qmu/preqmu.py
r25632 r25688 11 11 12 12 def preqmu(md, options): 13 """ QMU - apply Quantification of Margins and Uncertainties techniques13 """PREQMU - apply Quantification of Margins and Uncertainties techniques 14 14 to a solution sequence (like stressbalance.py, progonstic.py, etc ...), 15 15 using the Dakota software from Sandia. … … 36 36 options.addfielddefault('iparams', 0) 37 37 38 # when running in library mode, the in file needs to be called md.miscellaneous.name.qmu.in38 # When running in library mode, the in file needs to be called md.miscellaneous.name.qmu.in 39 39 qmufile = md.miscellaneous.name 40 40 41 # retrieve variables and resposnes for this particular analysis.41 # Retrieve variables and resposnes for this particular analysis. 42 42 #print type(md.qmu.variables) 43 43 #print md.qmu.variables.__dict__ 44 # print ivar44 # Print ivar 45 45 variables = md.qmu.variables #[ivar] 46 46 responses = md.qmu.responses #[iresp] 47 47 48 # expand variables and responses48 # Expand variables and responses 49 49 #print variables.__dict__ 50 50 #print responses.__dict__ … … 52 52 responses = expandresponses(md, responses) 53 53 54 # go through variables and responses, and check they don't have more than 55 # md.qmu.numberofpartitions values. Also determine numvariables and numresponses 54 # Go through variables and responses, and check they don't have more than 55 # md.qmu.numberofpartitions values. Also determine numvariables and 56 # numresponses 56 57 #{{{ 57 58 numvariables = 0 … … 82 83 #}}} 83 84 84 # create in file for dakota85 # Create in file for Dakota 85 86 #dakota_in_data(md.qmu.method[imethod], variables, responses, md.qmu.params[iparams], qmufile) 86 87 dakota_in_data(md.qmu.method, variables, responses, md.qmu.params, qmufile) 87 88 88 # build a list of variables and responses descriptors. the list is not expanded.89 # Build a list of variables and responses descriptors. the list is not expanded. 89 90 #{{{ 90 91 variabledescriptors = [] … … 115 116 #}}} 116 117 117 # build a list of variable partitions118 # Build a list of variable partitions 118 119 variablepartitions = [] 119 120 variablepartitions_npart = [] … … 125 126 if type(fieldvariable) in [list, np.ndarray]: 126 127 for j in range(np.size(fieldvariable)): 127 if fieldvariable[j].isscaled() :128 if fieldvariable[j].isscaled() or fieldvariable[j].isdistributed(): 128 129 variablepartitions.append(fieldvariable[j].partition) 129 130 variablepartitions_npart.append(qmupart2npart(fieldvariable[j].partition)) 130 variablepartitions_nt.append(fieldvariable[j].nsteps) 131 if hasattr(fieldvariable[j], 'nsteps'): 132 variablepartitions_nt.append(fieldvariable[j].nsteps) 133 else: 134 variablepartitions_nt.append(1) 131 135 else: 132 136 variablepartitions.append([]) … … 137 141 variablepartitions.append(fieldvariable.partition) 138 142 variablepartitions_npart.append(qmupart2npart(fieldvariable.partition)) 139 variablepartitions_nt.append(fieldvariable.nsteps) 143 if hasattr(fieldvariable, 'nsteps'): 144 variablepartitions_nt.append(fieldvariable.nsteps) 145 else: 146 variablepartitions_nt.append(1) 140 147 else: 141 148 variablepartitions.append([]) … … 143 150 variablepartitions_nt.append(1) 144 151 145 # build a list of response partitions152 # Build a list of response partitions 146 153 responsepartitions = [] 147 responsepartitions_npart = []154 responsepartitions_npart = np.array([]) 148 155 response_fieldnames = fieldnames(md.qmu.responses) 149 156 for i in range(len(response_fieldnames)): … … 154 161 if fieldresponse[j].isscaled(): 155 162 responsepartitions.append(fieldresponse[j].partition) 156 responsepartitions_npart .append(qmupart2npart(fieldresponse[j].partition))163 responsepartitions_npart = np.append(responsepartitions_npart, qmupart2npart(fieldresponse[j].partition)) 157 164 else: 158 165 responsepartitions.append([]) 159 responsepartitions_npart .append(0)166 responsepartitions_npart = np.append(responsepartitions_npart, 0) 160 167 else: 161 168 if fieldresponse.isscaled(): 162 169 responsepartitions.append(fieldresponse.partition) 163 responsepartitions_npart .append(qmupart2npart(fieldresponse.partition))170 responsepartitions_npart = np.append(responsepartitions_npart, qmupart2npart(fieldresponse.partition)) 164 171 else: 165 172 responsepartitions.append([]) 166 responsepartitions_npart .append(0)173 responsepartitions_npart = np.append(responsepartitions_npart, 0) 167 174 168 # register the fields that will be needed by the Qmu model. 175 if responsepartitions_npart.shape[0] != 1: 176 responsepartitions_npart = responsepartitions_npart.reshape(1, -1) 177 178 # Register the fields that will be needed by the Qmu model. 169 179 md.qmu.numberofresponses = numresponses 170 180 md.qmu.variabledescriptors = variabledescriptors … … 176 186 md.qmu.responsepartitions_npart = responsepartitions_npart 177 187 178 # now, we have to provide all the info necessary for the solutions to compute the179 # responses. For ex, if mass_flux is a response, we need a profile of points.180 # For a misfit, we need the observed velocity, etc ...188 # Now, we have to provide all the info necessary for the solutions to 189 # compute the responses. For example, if mass_flux is a response, we need a 190 # profile of points. For a misfit, we need the observed velocity, etc. 181 191 md = process_qmu_response_data(md) 182 192 -
issm/trunk-jpl/src/m/qmu/qmupart2npart.m
r24989 r25688 1 1 function npart=qmupart2npart(vector) 2 3 %vector is full of -1 (no partition) and 0 to npart. We need to 4 %identify npart 5 2 %vector is full of -1 (no partition) and 0 to npart. We need to identify npart= 6 3 npart=max(vector)+1; 7 8 -
issm/trunk-jpl/src/m/qmu/qmupart2npart.py
r25011 r25688 1 import numpy as np2 3 4 1 def qmupart2npart(vector): 5 2 # Vector is full of -1 (no partition) and 0 to npart. We need to identify 6 3 # npart. 7 8 npart = vector.max() + 1 4 npart = int(vector.max() + 1) # cast to int as we may have a NumPy floating point type, which cannot be used as an argument to function range (see src/m/qmu/setupdesign/QmuSetupVariables.py) 9 5 10 6 return npart -
issm/trunk-jpl/src/m/qmu/setupdesign/QmuSetupVariables.py
r25031 r25688 1 1 from copy import deepcopy 2 2 3 from helpers import * 3 4 from MatlabFuncs import * … … 8 9 9 10 def QmuSetupVariables(md, variables): 10 #get descriptor 11 """QMUSETUPVARIABLES function 12 """ 13 14 # Get descriptor 11 15 descriptor = variables.descriptor 12 16 13 #decide whether this is a distributed variable, which will drive whether we expand it into npart values, 14 #or if we just carry it forward as is. 17 # Decide whether this is a distributed variable, which will drive whether we expand it into npart values, or if we just carry it forward as is 15 18 19 # Ok, key off according to type of descriptor 16 20 dvar = [] 21 if strncmp(descriptor, 'scaled_', 7): 22 # We have a scaled variable, expand it over the partition. First recover the partition. 23 partition = variables.partition 24 # Figure out number of partitions 25 npart = qmupart2npart(partition) 17 26 18 #ok, key off according to type of descriptor: 19 if strncmp(descriptor, 'scaled_', 7): 20 #we have a scaled variable, expand it over the partition. First recover the partition. 21 partition = variables.partition 22 #figure out number of partitions 23 npart = qmupart2npart(partition) 24 #figure out number of time steps 27 # Figure out number of time steps 25 28 nt = variables.nsteps 26 29 … … 44 47 raise RuntimeError('QmuSetupVariables error message: stddev and mean fields should have the same number of cols as the number of time steps') 45 48 46 #ok, dealing with semi-discrete distributed variable. Distribute according to how many 47 #partitions we want, and number of time steps 49 # Ok, dealing with semi-discrete distributed variable. Distribute according to how many partitions we want, and number of time steps 48 50 if nt == 1: 49 51 for j in range(npart): 50 52 dvar.append(deepcopy(variables)) 51 53 52 # text parsing in dakota requires literal "'identifier'" not just "identifier"54 # Text parsing in Dakota requires literal "'identifier'" not just "identifier" 53 55 dvar[-1].descriptor = "'" + str(variables.descriptor) + '_' + str(j + 1) + "'" 54 56 … … 64 66 dvar.append(deepcopy(variables)) 65 67 66 # text parsing in dakota requires literal "'identifier'" not just "identifier"68 # Text parsing in Dakota requires literal "'identifier'" not just "identifier" 67 69 dvar[-1].descriptor = "'" + str(variables.descriptor) + '_' + str(j + 1) + '_' + str(k + 1) + "'" 68 70 … … 76 78 dvar.append(deepcopy(variables)) 77 79 78 # text parsing in dakota requires literal "'identifier'" not just "identifier"80 # text parsing in Dakota requires literal "'identifier'" not just "identifier" 79 81 dvar[-1].descriptor = "'" + str(variables.descriptor) + "'" 80 82 -
issm/trunk-jpl/src/m/solve/WriteData.py
r25515 r25688 164 164 for i in range(s[0]): 165 165 if np.ndim(data) == 1: 166 fid.write(pack('d', float(data[i]))) #get to the "c" convention, hence the transpose166 fid.write(pack('d', float(data[i]))) 167 167 else: 168 168 for j in range(s[1]): 169 fid.write(pack('d', float(data[i][j]))) #get to the "c" convention, hence the transpose169 fid.write(pack('d', float(data[i][j]))) 170 170 # }}} 171 171 … … 352 352 353 353 def FormatToCode(datatype): # {{{ 354 """ 355 This routine takes the datatype string, and hardcodes it into an integer, which 356 is passed along the record, in order to identify the nature of the dataset being 357 sent. 354 """ FORMATTOCODE - This routine takes the datatype string, and hardcodes it 355 into an integer, which is passed along the record, in order to identify the 356 nature of the dataset being sent. 358 357 """ 359 358 if datatype == 'Boolean': -
issm/trunk-jpl/src/m/solve/loadresultsfromcluster.py
r25685 r25688 43 43 if md.qmu.output and md.qmu.statistics.method[0]['name'] == 'None': 44 44 if md.qmu.method.method == 'nond_sampling': 45 for i in range( len(md.qmu.method.params.samples)):46 filelist.append(md.miscellaneous.name + '.outbin ' + str(i))45 for i in range(md.qmu.method.params.samples): 46 filelist.append(md.miscellaneous.name + '.outbin.' + str(i + 1)) 47 47 if md.qmu.statistics.method[0]['name'] != 'None': 48 48 filelist.append(md.miscellaneous.name + '.stats') -
issm/trunk-jpl/src/m/solve/loadresultsfromdisk.m
r25627 r25688 62 62 63 63 if ~isempty(md.results.(structure(1).SolutionType)(1).errlog), 64 disp(['loadresultsfrom clusterinfo message: error during solution. Check your errlog and outlog model fields']);64 disp(['loadresultsfromdisk info message: error during solution. Check your errlog and outlog model fields']); 65 65 end 66 66 -
issm/trunk-jpl/src/m/solve/loadresultsfromdisk.py
r25685 r25688 1 1 import os 2 3 import numpy as np # Remove: used temporarily for debugging 2 4 3 5 from helpers import fieldnames … … 40 42 if not structure: 41 43 raise RuntimeError("No result found in binary file '{}'. Check for solution crash.".format(filename)) 42 if not structure[0].SolutionType:43 if structure[-1].SolutionType:44 if not hasattr(structure[0], 'SolutionType'): 45 if hasattr(structure[-1], 'SolutionType'): 44 46 structure[0].SolutionType = structure[-1].SolutionType 45 47 else: … … 65 67 66 68 if getattr(md.results, structure[0].SolutionType)[0].errlog: 67 print("loadresultsfrom clusterinfo message: error during solution. Check your errlog and outlog model fields.")69 print("loadresultsfromdisk info message: error during solution. Check your errlog and outlog model fields.") 68 70 69 71 # If only one solution, extract it from list for user friendliness -
issm/trunk-jpl/src/m/solve/marshall.m
r25499 r25688 18 18 end 19 19 20 % Go through all model fields: check that it is a class and call checkconsistency21 fields= properties('model');20 % Go through all model fields: check that it is a class and call checkconsistency 21 fields=sort(properties('model')); %sort fields so that comparison of binary files is easier 22 22 for i=1:length(fields), 23 23 field=fields{i}; … … 43 43 %close file 44 44 st=fclose(fid); 45 % % Uncomment the following to make a copy of the binary input file for debugging 46 % % purposes (can be fed into scripts/ReadBin.py). 47 copyfile([md.miscellaneous.name '.bin'], [md.miscellaneous.name '.m.bin']) 45 46 % Uncomment the following to make a copy of the binary input file for debugging 47 % purposes (can be fed into scripts/ReadBin.py). 48 % copyfile([md.miscellaneous.name '.bin'], [md.miscellaneous.name '.m.bin']) 49 48 50 if st==-1, 49 51 error(['marshall error message: could not close file ' [md.miscellaneous.name '.bin']]); -
issm/trunk-jpl/src/m/solve/marshall.py
r25499 r25688 5 5 6 6 def marshall(md): 7 ''' 8 MARSHALL - outputs a compatible binary file from @model md, for certain solution type. 7 """MARSHALL - outputs a compatible binary file from @model md, for certain solution type. 9 8 10 11 This binary file will be used for parallel runs in JPL-package9 The routine creates a compatible binary file from @model md 10 his binary file will be used for parallel runs in JPL-package 12 11 13 Usage: 14 marshall(md) 15 ''' 12 Usage: 13 marshall(md) 14 """ 15 16 16 if md.verbose.solution: 17 17 print("marshalling file {}.bin".format(md.miscellaneous.name)) … … 23 23 raise IOError("marshall error message: could not open '%s.bin' file for binary writing. Due to: ".format(md.miscellaneous.name), e) 24 24 25 for field in md.properties(): 25 fields = md.properties() 26 fields.sort() # sort fields so that comparison of binary files is easier 27 for field in fields: 26 28 #Some properties do not need to be marshalled 27 29 if field in ['results', 'radaroverlay', 'toolkits', 'cluster', 'private']: … … 42 44 try: 43 45 fid.close() 44 # # Uncomment the following to make a copy of the binary input file for 45 # # debugging purposes (can be fed into scripts/ReadBin.py). 46 copy_cmd = "cp {}.bin {}.py.bin".format(md.miscellaneous.name, md.miscellaneous.name) 47 subprocess.call(copy_cmd, shell=True) 46 47 # Uncomment the following to make a copy of the binary input file for 48 # debugging purposes (can be fed into scripts/ReadBin.py). 49 # copy_cmd = "cp {}.bin {}.py.bin".format(md.miscellaneous.name, md.miscellaneous.name) 50 # subprocess.call(copy_cmd, shell=True) 51 48 52 except IOError as e: 49 53 print("marshall error message: could not close file '{}.bin' due to:".format(md.miscellaneous.name), e) -
issm/trunk-jpl/src/m/solve/parseresultsfromdisk.m
r25627 r25688 1 function results=parseresultsfromdisk(md,filename,iosplit) 1 function results=parseresultsfromdisk(md,filename,iosplit) % {{{ 2 2 3 3 if iosplit, … … 7 7 %results=parseresultsfromdiskioserialsequential(md,filename); 8 8 end 9 10 function results=parseresultsfromdiskios erialsequential(md,filename) % {{{9 % }}} 10 function results=parseresultsfromdiskiosplit(md,filename) % {{{ 11 11 12 12 %Open file … … 15 15 error(['loadresultsfromdisk error message: could not open ',filename,' for binary reading']); 16 16 end 17 18 %first pass to figure out the steps we have: 19 steps=[]; 20 while 1, 21 result = ReadDataDimensions(fid); 22 if isempty(result), 23 break; 24 end 25 if result.step~=-9999, 26 steps=[steps result.step]; 27 end 28 end 29 30 steps=unique(steps); 31 32 %create structure: 33 results=struct('step',num2cell(steps)); 34 35 %second pass to fill the steps we have: 17 results=struct(); 18 19 %if we have done split I/O, ie, we have results that are fragmented across patches, 20 %do a first pass, and figure out the structure of results 21 result=ReadDataDimensions(fid); 22 while ~isempty(result), 23 24 %Get time and step 25 results(result.step).step=result.step; 26 if result.time~=-9999, 27 results(result.step).time=result.time; 28 end 29 30 %Add result 31 results(result.step).(result.fieldname)=NaN; 32 33 %read next result 34 result=ReadDataDimensions(fid); 35 end 36 37 %do a second pass, and figure out the size of the patches 36 38 fseek(fid,0,-1); %rewind 37 while 1, 38 result = ReadData(fid,md); 39 if isempty(result), 40 break; 41 end 42 if result.step==-9999, 43 result.step=1; 44 result.time=0; 45 end 46 %find where we are putting this step: 47 ind=find(steps==result.step); 48 if isempty(ind), 49 error('could not find a step in our pre-structure! Something is very off!'); 50 end 51 52 %plug: 53 results(ind).time=result.time; 54 results(ind).(result.fieldname)=result.field; 55 end 39 result=ReadDataDimensions(fid); 40 while ~isempty(result), 41 %read next result 42 result=ReadDataDimensions(fid); 43 end 44 45 %third pass, this time to read the real information 46 fseek(fid,0,-1); %rewind 47 result=ReadData(fid,md); 48 while ~isempty(result), 49 50 %Get time and step 51 results(result.step).step=result.step; 52 if result.time~=-9999, 53 results(result.step).time=result.time; 54 end 55 56 %Add result 57 results(result.step).(result.fieldname)=result.field; 58 59 %read next result 60 try, 61 result=ReadData(fid,md); 62 catch me, 63 disp('WARNING: file corrupted, results partial recovery'); 64 result=[]; 65 end 66 67 end 68 69 %close file 56 70 fclose(fid); 57 71 % }}} … … 71 85 %read next result 72 86 try, 73 result 87 result = ReadData(fid,md); 74 88 catch me, 75 89 disp('WARNING: file corrupted, trying partial recovery'); … … 92 106 fclose(fid); 93 107 94 %Now, process all results and find how many steps we have108 %Now, process all results and find out how many steps we have 95 109 numresults = numel(allresults); 96 110 allsteps = zeros(numresults,1); … … 105 119 for i=1:numresults 106 120 result = allresults{i}; 107 108 121 index = 1; 109 if result.step ~= -9999122 if(result.step ~= -9999) 110 123 index = find(result.step == allsteps); 111 end 112 113 if(result.step~=-9999) results(index).step=result.step; end 114 if(result.time~=-9999) results(index).time=result.time; end 124 results(index).step=result.step; 125 end 126 if(result.time~=-9999) 127 results(index).time=result.time; 128 end 115 129 results(index).(result.fieldname)=result.field; 116 130 end 117 131 % }}} 118 function results=parseresultsfromdiskios plit(md,filename) % {{{132 function results=parseresultsfromdiskioserialsequential(md,filename) % {{{ 119 133 120 134 %Open file … … 123 137 error(['loadresultsfromdisk error message: could not open ',filename,' for binary reading']); 124 138 end 125 results=struct(); 126 127 %if we have done split I/O, ie, we have results that are fragmented across patches, 128 %do a first pass, and figure out the structure of results 129 result=ReadDataDimensions(fid); 130 while ~isempty(result), 131 132 %Get time and step 133 results(result.step).step=result.step; 134 if result.time~=-9999, 135 results(result.step).time=result.time; 136 end 137 138 %Add result 139 results(result.step).(result.fieldname)=NaN; 140 141 %read next result 142 result=ReadDataDimensions(fid); 143 end 144 145 %do a second pass, and figure out the size of the patches 139 140 %first pass to figure out the steps we have: 141 steps=[]; 142 while 1, 143 result = ReadDataDimensions(fid); 144 if isempty(result), 145 break; 146 end 147 if result.step~=-9999, 148 steps=[steps result.step]; 149 end 150 end 151 152 steps=unique(steps); 153 154 %create structure: 155 results=struct('step',num2cell(steps)); 156 157 %second pass to fill the steps we have: 146 158 fseek(fid,0,-1); %rewind 147 result=ReadDataDimensions(fid); 148 while ~isempty(result), 149 %read next result 150 result=ReadDataDimensions(fid); 151 end 152 153 %third pass, this time to read the real information 154 fseek(fid,0,-1); %rewind 155 result=ReadData(fid,md); 156 while ~isempty(result), 157 158 %Get time and step 159 results(result.step).step=result.step; 160 if result.time~=-9999, 161 results(result.step).time=result.time; 162 end 163 164 %Add result 165 results(result.step).(result.fieldname)=result.field; 166 167 %read next result 168 try, 169 result=ReadData(fid,md); 170 catch me, 171 disp('WARNING: file corrupted, results partial recovery'); 172 result=[]; 173 end 174 175 end 176 177 %close file 159 while 1, 160 result = ReadData(fid,md); 161 if isempty(result), 162 break; 163 end 164 if result.step==-9999, 165 result.step=1; 166 result.time=0; 167 end 168 %find where we are putting this step: 169 ind=find(steps==result.step); 170 if isempty(ind), 171 error('could not find a step in our pre-structure! Something is very off!'); 172 end 173 174 %plug: 175 results(ind).time=result.time; 176 results(ind).(result.fieldname)=result.field; 177 end 178 178 fclose(fid); 179 %}}}179 %}}} 180 180 function result=ReadData(fid,md) % {{{ 181 181 … … 312 312 end 313 313 314 if time~=-9999, 315 time=time/yts; 316 end 317 314 318 result.fieldname=fieldname; 315 319 result.time=time; 316 if result.time~=-9999,317 result.time=time/yts;318 end319 320 result.step=step; 320 321 result.field=field; -
issm/trunk-jpl/src/m/solve/parseresultsfromdisk.py
r25303 r25688 1 from collections import OrderedDict 1 2 import struct 3 2 4 import numpy as np 3 from collections import OrderedDict 5 4 6 import results as resultsclass 5 7 6 8 7 def parseresultsfromdisk(md, filename, iosplit): 9 def parseresultsfromdisk(md, filename, iosplit): #{{{ 8 10 if iosplit: 9 11 saveres = parseresultsfromdiskiosplit(md, filename) 10 12 else: 11 13 saveres = parseresultsfromdiskioserial(md, filename) 12 return saveres 13 14 #saveres = parseresultsfromdiskioserialsequential(md, filename) 15 return saveres 16 #}}} 17 18 def parseresultsfromdiskiosplit(md, filename): # {{{ 19 #Open file 20 try: 21 fid = open(filename, 'rb') 22 except IOError as e: 23 raise IOError("parseresultsfromdisk error message: could not open '{}' for binary reading.".format(filename)) 24 25 saveres = [] 26 27 #if we have done split I / O, ie, we have results that are fragmented across patches, 28 #do a first pass, and figure out the structure of results 29 loadres = ReadDataDimensions(fid) 30 while loadres: 31 32 #Get time and step 33 if loadres['step'] > len(saveres): 34 for i in range(len(saveres), loadres['step'] - 1): 35 saveres.append(None) 36 saveres.append(resultsclass.results()) 37 setattr(saveres[loadres['step'] - 1], 'step', loadres['step']) 38 setattr(saveres[loadres['step'] - 1], 'time', loadres['time']) 39 40 #Add result 41 setattr(saveres[loadres['step'] - 1], loadres['fieldname'], float('NaN')) 42 43 #read next result 44 loadres = ReadDataDimensions(fid) 45 46 #do a second pass, and figure out the size of the patches 47 fid.seek(0) #rewind 48 loadres = ReadDataDimensions(fid) 49 while loadres: 50 51 #read next result 52 loadres = ReadDataDimensions(fid) 53 54 #third pass, this time to read the real information 55 fid.seek(0) #rewind 56 loadres = ReadData(fid, md) 57 while loadres: 58 59 #Get time and step 60 if loadres['step'] > len(saveres): 61 for i in range(len(saveres), loadres['step'] - 1): 62 saveres.append(None) 63 saveres.append(saveresclass.saveres()) 64 setattr(saveres[loadres['step'] - 1], 'step', loadres['step']) 65 setattr(saveres[loadres['step'] - 1], 'time', loadres['time']) 66 67 #Add result 68 setattr(saveres[loadres['step'] - 1], loadres['fieldname'], loadres['field']) 69 70 #read next result 71 loadres = ReadData(fid, md) 72 73 #close file 74 fid.close() 75 76 return saveres 77 # }}} 14 78 15 79 def parseresultsfromdiskioserial(md, filename): # {{{ … … 73 137 74 138 return saveres 75 # }}} 76 77 78 def parseresultsfromdiskiosplit(md, filename): # {{{ 79 #Open file 80 try: 81 fid = open(filename, 'rb') 82 except IOError as e: 83 raise IOError("loadresultsfromdisk error message: could not open '{}' for binary reading.".format(filename)) 84 85 saveres = [] 86 87 #if we have done split I / O, ie, we have results that are fragmented across patches, 88 #do a first pass, and figure out the structure of results 89 loadres = ReadDataDimensions(fid) 90 while loadres: 91 92 #Get time and step 93 if loadres['step'] > len(saveres): 94 for i in range(len(saveres), loadres['step'] - 1): 95 saveres.append(None) 96 saveres.append(resultsclass.results()) 97 setattr(saveres[loadres['step'] - 1], 'step', loadres['step']) 98 setattr(saveres[loadres['step'] - 1], 'time', loadres['time']) 99 100 #Add result 101 setattr(saveres[loadres['step'] - 1], loadres['fieldname'], float('NaN')) 102 103 #read next result 104 loadres = ReadDataDimensions(fid) 105 106 #do a second pass, and figure out the size of the patches 107 fid.seek(0) #rewind 108 loadres = ReadDataDimensions(fid) 109 while loadres: 110 111 #read next result 112 loadres = ReadDataDimensions(fid) 113 114 #third pass, this time to read the real information 115 fid.seek(0) #rewind 116 loadres = ReadData(fid, md) 117 while loadres: 118 119 #Get time and step 120 if loadres['step'] > len(saveres): 121 for i in range(len(saveres), loadres['step'] - 1): 122 saveres.append(None) 123 saveres.append(saveresclass.saveres()) 124 setattr(saveres[loadres['step'] - 1], 'step', loadres['step']) 125 setattr(saveres[loadres['step'] - 1], 'time', loadres['time']) 126 127 #Add result 128 setattr(saveres[loadres['step'] - 1], loadres['fieldname'], loadres['field']) 129 130 #read next result 131 loadres = ReadData(fid, md) 132 133 #close file 134 fid.close() 135 136 return saveres 137 # }}} 138 139 # }}} 139 140 140 141 def ReadData(fid, md): # {{{ 141 ''' 142 READDATA - 143 144 Usage: 145 field = ReadData(fid, md) 146 ''' 142 """READDATA 143 144 Usage: 145 field = ReadData(fid, md) 146 """ 147 147 148 148 #read field … … 291 291 292 292 return saveres 293 293 # }}} 294 294 295 295 296 296 def ReadDataDimensions(fid): # {{{ 297 """READDATADIMENSIONS - read data dimensions, step and time, but not the data itself. 298 299 Usage: 300 field = ReadDataDimensions(fid) 297 301 """ 298 READDATADIMENSIONS - read data dimensions, step and time, but not the data itself. 299 300 Usage: 301 field = ReadDataDimensions(fid) 302 """ 303 304 #read field 302 303 # Read field 305 304 try: 306 305 length = struct.unpack('i', fid.read(struct.calcsize('i')))[0] … … 310 309 datatype = struct.unpack('i', fid.read(struct.calcsize('i')))[0] 311 310 M = struct.unpack('i', fid.read(struct.calcsize('i')))[0] 312 N = 1 #default311 N = 1 # default 313 312 if datatype == 1: 314 313 fid.seek(M * 8, 1) … … 333 332 334 333 return saveres 335 334 # }}} -
issm/trunk-jpl/src/wrappers/CoordTransform
-
Property svn:ignore
set to
.deps
-
Property svn:ignore
set to
-
issm/trunk-jpl/test
- Property svn:mergeinfo changed
/issm/branches/trunk-larour-SLPS2020/test (added) merged: 25526-25527,25595,25604,25606-25607
- Property svn:mergeinfo changed
-
issm/trunk-jpl/test/NightlyRun
- Property svn:ignore
-
old new 18 18 run.old 19 19 run_matlab 20 test218.qmu.in 21 test218.qmu.out 22 test218.qmu.err
-
- Property svn:ignore
-
issm/trunk-jpl/test/NightlyRun/runme.m
r25670 r25688 107 107 %Process Ids according to benchmarks{{{ 108 108 if strcmpi(benchmark,'nightly'), 109 test_ids=intersect(test_ids, [1:999]);109 test_ids=intersect(test_ids,union([1:999],[2001:2500])); 110 110 elseif strcmpi(benchmark,'validation'), 111 111 test_ids=intersect(test_ids,[1001:1999]); … … 219 219 archive_cell=archread(['../Archives/' archive_name '.arch'],[archive_name '_field' num2str(k)]); 220 220 archive=archive_cell{1}; 221 error_diff=full(max(abs(archive(:)-field(:)))/(max(abs(archive(:)))+eps)); 222 223 %disp test result 221 error_diff=full(max(abs(archive(:)-field(:)))/(max(abs(archive(:)))+eps)); %disp test result 224 222 if (error_diff>tolerance | isnan(error_diff)); 225 223 disp(sprintf(['ERROR difference: %-7.2g > %7.2g test id: %i test name: %s field: %s'],... -
issm/trunk-jpl/test/NightlyRun/runme.py
r25670 r25688 114 114 #Process Ids according to benchmarks {{{ 115 115 if benchmark == 'nightly': 116 test_ids = test_ids.intersection(set(range(1, 1000)) )116 test_ids = test_ids.intersection(set(range(1, 1000)).union(set(range(2001, 2500)))) 117 117 elif benchmark == 'validation': 118 118 test_ids = test_ids.intersection(set(range(1001, 2000))) -
issm/trunk-jpl/test/NightlyRun/test2002.py
r25181 r25688 52 52 53 53 #make sure wherever there is an ice load, that the mask is set to ice: 54 #pos = np.nonzero(md.solidearth.surfaceload.icethicknesschange)[0] # Do we need to do this twice?54 #pos = np.nonzero(md.solidearth.surfaceload.icethicknesschange)[0] # TODO: Do we need to do this twice? 55 55 md.mask.ice_levelset[md.mesh.elements[pos, :] - 1] = -1 56 56 # }}} … … 72 72 md.solidearth.settings.computesealevelchange = 1 73 73 74 #max number of iteration reverted back to 10 (i.e., the original default value)74 #max number of iterations reverted back to 10 (i.e., the original default value) 75 75 md.solidearth.settings.maxiter = 10 76 76 -
issm/trunk-jpl/test/NightlyRun/test2005.m
r25627 r25688 40 40 41 41 %make sure wherever there is an ice load, that the mask is set to ice: 42 pos=find(md.solidearth.surfaceload.icethicknesschange); 42 %pos=find(md.solidearth.surfaceload.icethicknesschange); % TODO: Do we need to do this twice? 43 43 md.mask.ice_levelset(md.mesh.elements(pos,:))=-1; 44 44 % }}} … … 51 51 %Materials: 52 52 md.materials=materials('hydro'); 53 54 53 55 54 %Miscellaneous … … 86 85 deltathickness(end,:)=0:1:9; 87 86 md.solidearth.surfaceload.icethicknesschange=deltathickness; 88 89 87 %hack: 90 88 md.geometry.surface=zeros(md.mesh.numberofvertices,1); … … 103 101 %Fields and tolerances to track changes 104 102 field_names={'Sealevel1','Sealevel5','Sealevel10','Seustatic10'}; 105 field_tolerances={1e-13,1e-13,1e-13,1e-13 ,1e-13};103 field_tolerances={1e-13,1e-13,1e-13,1e-13}; 106 104 field_values={S1,S5,S10,Seus10}; 107 105 -
issm/trunk-jpl/test/NightlyRun/test2006.m
r25627 r25688 52 52 %Materials: 53 53 md.materials=materials('hydro'); 54 55 54 56 55 %Miscellaneous … … 138 137 end 139 138 % }}} 140 %algorithm: % {{{ 141 md.qmu.method =dakota_method('nond_samp'); 142 md.qmu.method(end)=dmeth_params_set(md.qmu.method(end),... 143 'seed',1234,... 144 'samples',10,... 145 'sample_type','random'); 146 md.qmu.output=1; 147 %}}} 148 %parameters % {{{ 149 md.qmu.params.direct=true; 150 md.qmu.params.interval_type='forward'; 151 md.qmu.params.analysis_driver='matlab'; 152 md.qmu.params.evaluation_scheduling='master'; 153 md.qmu.params.processors_per_evaluation=2; 154 md.qmu.params.tabular_graphics_data=true; 155 md.qmu.isdakota=1; 156 md.verbose=verbose(0); md.verbose.qmu=1; 157 % }}} 158 %qmu statistics %{{{ 159 md.qmu.statistics.nfiles_per_directory=2; 160 md.qmu.statistics.ndirectories=5; 161 162 md.qmu.statistics.method(1).name='Histogram'; 163 md.qmu.statistics.method(1).fields={'Sealevel','BslrIce'}; 164 md.qmu.statistics.method(1).steps=1:10; 165 md.qmu.statistics.method(1).nbins=20; 166 167 md.qmu.statistics.method(2).name='MeanVariance'; 168 md.qmu.statistics.method(2).fields={'Sealevel','BslrIce'}; 169 md.qmu.statistics.method(2).steps=[1:10]; 170 171 md.qmu.statistics.method(3).name='SampleSeries'; 172 md.qmu.statistics.method(3).fields={'Sealevel','BslrIce'}; 173 md.qmu.statistics.method(3).steps=[1:10]; 174 md.qmu.statistics.method(3).indices=locations; 175 %}}} 139 140 %algorithm: % {{{ 141 md.qmu.method =dakota_method('nond_samp'); 142 md.qmu.method(end)=dmeth_params_set(md.qmu.method(end),... 143 'seed',1234,... 144 'samples',10,... 145 'sample_type','random'); 146 md.qmu.output=1; 147 %}}} 148 %parameters % {{{ 149 md.qmu.params.direct=true; 150 md.qmu.params.interval_type='forward'; 151 md.qmu.params.analysis_driver='matlab'; 152 md.qmu.params.evaluation_scheduling='master'; 153 md.qmu.params.processors_per_evaluation=2; 154 md.qmu.params.tabular_graphics_data=true; 155 md.qmu.isdakota=1; 156 md.verbose=verbose(0); md.verbose.qmu=1; 157 % }}} 158 %qmu statistics %{{{ 159 md.qmu.statistics.nfiles_per_directory=2; 160 md.qmu.statistics.ndirectories=5; 161 162 md.qmu.statistics.method(1).name='Histogram'; 163 md.qmu.statistics.method(1).fields={'Sealevel','BslrIce'}; 164 md.qmu.statistics.method(1).steps=[1:10]; 165 md.qmu.statistics.method(1).nbins=20; 166 167 md.qmu.statistics.method(2).name='MeanVariance'; 168 md.qmu.statistics.method(2).fields={'Sealevel','BslrIce'}; 169 md.qmu.statistics.method(2).steps=[1:10]; 170 171 md.qmu.statistics.method(3).name='SampleSeries'; 172 md.qmu.statistics.method(3).fields={'Sealevel','BslrIce'}; 173 md.qmu.statistics.method(3).steps=[1:10]; 174 md.qmu.statistics.method(3).indices=locations; 175 %}}} 176 176 177 177 %run transient dakota solution: … … 182 182 md=solve(md,'Transient'); 183 183 184 %compare statistics with our own here: 184 disp(mds.results.StatisticsSolution) 185 186 %compare statistics with our own here: 185 187 svalues=mds.results.StatisticsSolution(end).SealevelSamples; %all values at locations. 186 188 … … 190 192 end 191 193 194 disp(dvalues) 195 disp(size(dvalues)) 196 192 197 samplesnorm=norm(dvalues-svalues,'fro'); 193 198
Note:
See TracChangeset
for help on using the changeset viewer.