source:
issm/oecreview/Archive/24684-25833/ISSM-25168-25169.diff@
27230
Last change on this file since 27230 was 25834, checked in by , 4 years ago | |
---|---|
File size: 67.7 KB |
-
../trunk-jpl/src/m/classes/matdamageice.py
129 129 md = checkfield(md, 'fieldname', 'materials.mantle_shear_modulus', '>', 0, 'numel', [1]) 130 130 md = checkfield(md, 'fieldname', 'materials.mantle_density', '>', 0, 'numel', [1]) 131 131 md = checkfield(md, 'fieldname', 'materials.earth_density', '>', 0, 'numel', [1]) 132 133 if 'GiaAnalysis' in analyses: 134 md = checkfield(md, 'fieldname', 'materials.lithosphere_shear_modulus', '>', 0, 'numel', 1) 135 md = checkfield(md, 'fieldname', 'materials.lithosphere_density', '>', 0, 'numel', 1) 136 md = checkfield(md,'fieldname', 'materials.mantle_shear_modulus', '>', 0, 'numel', 1) 137 md = checkfield(md,'fieldname', 'materials.mantle_density', '>', 0, 'numel', 1) 138 139 if 'SealevelriseAnalysis' in analyses: 140 md = checkfield(md, 'fieldname', 'materials.earth_density', '>', 0, 'numel', 1) 141 132 142 return md 133 143 # }}} 134 144 -
../trunk-jpl/src/m/classes/toolkits.m
4 4 % self=toolkits(); 5 5 6 6 classdef toolkits < dynamicprops 7 8 9 10 11 12 13 14 15 7 properties (SetAccess=public) 8 DefaultAnalysis = struct(); 9 RecoveryAnalysis = struct(); 10 %The other properties are dynamic 11 end 12 methods (Static) 13 function self = loadobj(self) % {{{ 14 % This function is directly called by matlab when a model object is 15 % loaded. Update old properties here 16 16 17 if isempty(fieldnames(self.RecoveryAnalysis)); 18 disp('WARNING: updating toolkits (RecoveryAnalysis not set)'); 19 self.RecoveryAnalysis = self.DefaultAnalysis; 20 end 21 end% }}} 22 end 23 methods 24 function self = toolkits(varargin) % {{{ 25 switch nargin 26 case 0 27 self=setdefaultparameters(self); 28 case 1 29 self=structtoobj(self,varargin{1}); 30 otherwise 31 error('constructor not supported'); 32 end 33 end % }}} 34 function self = addoptions(self,analysis,varargin) % {{{ 35 % Usage example: 36 % md.toolkits=addoptions(md.toolkits,'StressbalanceAnalysis',FSoptions()); 37 % md.toolkits=addoptions(md.toolkits,'StressbalanceAnalysis'); 17 if isempty(fieldnames(self.RecoveryAnalysis)); 18 disp('WARNING: updating toolkits (RecoveryAnalysis not set)'); 19 self.RecoveryAnalysis = self.DefaultAnalysis; 20 end 21 end% }}} 22 end 23 methods 24 function self = toolkits(varargin) % {{{ 25 switch nargin 26 case 0 27 self=setdefaultparameters(self); 28 case 1 29 self=structtoobj(self,varargin{1}); 30 otherwise 31 error('constructor not supported'); 32 end 33 end % }}} 34 function self = addoptions(self,analysis,varargin) % {{{ 35 %ADDOPTIONS - add analysis to md.toolkits.analysis 36 % 37 % Optional third parameter adds toolkits options to analysis. 38 % 39 % Usage: 40 % md.toolkits=addoptions(md.toolkits,'StressbalanceAnalysis',FSoptions()); 41 % md.toolkits=addoptions(md.toolkits,'StressbalanceAnalysis'); 38 42 39 40 41 42 43 %Create dynamic property if property does not exist yet 44 if ~ismember(analysis,properties(self)), 45 self.addprop(analysis); 46 end 43 47 44 %Add toolkits options to analysis 45 if nargin==3, self.(analysis) = varargin{1}; end 46 end 47 %}}} 48 function self = setdefaultparameters(self) % {{{ 48 %Add toolkits options to analysis 49 if nargin==3, 50 self.(analysis) = varargin{1}; 51 end 52 end 53 %}}} 54 function self = setdefaultparameters(self) % {{{ 49 55 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 56 %default toolkits: 57 if IssmConfig('_HAVE_PETSC_'), 58 %MUMPS is the default toolkits 59 if IssmConfig('_HAVE_MUMPS_'), 60 self.DefaultAnalysis = mumpsoptions(); 61 else 62 self.DefaultAnalysis = iluasmoptions(); 63 end 64 else 65 if IssmConfig('_HAVE_MUMPS_'), 66 self.DefaultAnalysis = issmmumpssolver(); 67 elseif IssmConfig('_HAVE_GSL_'), 68 self.DefaultAnalysis = issmgslsolver(); 69 else 70 disp('WARNING: Need at least Mumps or Gsl to define an issm solver type, no default solver assigned'); 71 end 72 end 67 73 68 69 74 %Use same solver for Recovery mode 75 self.RecoveryAnalysis = self.DefaultAnalysis; 70 76 71 77 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 78 end % }}} 79 function disp(self) % {{{ 80 analyses=properties(self); 81 disp(sprintf('List of toolkits options per analysis:\n')); 82 for i=1:numel(analyses), 83 analysis=analyses{i}; 84 disp([analysis ':']); 85 disp(self.(analysis)); 86 end 87 end % }}} 88 function md = checkconsistency(self,md,solution,analyses) % {{{ 89 analyses=properties(self); 90 for i=1:numel(analyses), 91 switch analyses{i} 92 case 'DefaultAnalysis' 93 case 'RecoveryAnalysis' 94 case 'StressbalanceAnalysis' 95 case 'GLheightadvectionAnalysis' 96 case 'MasstransportAnalysis' 97 case 'ThermalAnalysis' 98 case 'EnthalpyAnalysis' 99 case 'AdjointBalancethicknessAnalysis' 100 case 'BalancethicknessAnalysis' 101 case 'Balancethickness2Analysis' 102 case 'BalancethicknessSoftAnalysis' 103 case 'BalancevelocityAnalysis' 104 case 'DamageEvolutionAnalysis' 105 case 'LoveAnalysis' 106 case 'EsaAnalysis' 107 case 'SealevelriseAnalysis' 108 otherwise 103 109 md = checkmessage(md,['md.toolkits.' analyses{i} ' not supported yet']); 104 105 106 107 108 109 110 111 112 113 114 115 116 110 end 111 if isempty(fieldnames(self.(analyses{i}))) 112 md = checkmessage(md,['md.toolkits.' analyses{i} ' is empty']); 113 end 114 end 115 end % }}} 116 function ToolkitsFile(toolkits,filename) % {{{ 117 %TOOLKITSFILE - build toolkits file 118 % 119 % Build a Petsc compatible options file, from the toolkits model field + return options string. 120 % This file will also be used when the toolkit used is 'issm' instead of 'petsc' 121 % 122 % Usage: ToolkitsFile(toolkits,filename); 117 123 118 119 120 121 122 124 %open file for writing 125 fid=fopen(filename,'w'); 126 if fid==-1, 127 error(['ToolkitsFile error: could not open ' filename ' for writing']); 128 end 123 129 124 125 130 %write header 131 fprintf(fid,'%s%s%s\n','%Toolkits options file: ',filename,' written from Matlab toolkits array'); 126 132 127 128 129 130 131 133 %start writing options 134 analyses=properties(toolkits); 135 for i=1:numel(analyses), 136 analysis=analyses{i}; 137 options=toolkits.(analysis); 132 138 133 134 139 %first write analysis: 140 fprintf(fid,'\n+%s\n',analysis); %append a + to recognize it's an analysis enum 135 141 136 137 138 139 140 142 %now, write options 143 optionslist=fieldnames(options); 144 for j=1:numel(optionslist), 145 optionname=optionslist{j}; 146 optionvalue=options.(optionname); 141 147 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 148 if isempty(optionvalue), 149 %this option has only one argument 150 fprintf(fid,'-%s\n',optionname); 151 else 152 %option with value. value can be string or scalar 153 if isnumeric(optionvalue), 154 fprintf(fid,'-%s %g\n',optionname,optionvalue); 155 elseif ischar(optionvalue), 156 fprintf(fid,'-%s %s\n',optionname,optionvalue); 157 else 158 error(['ToolkitsFile error: option ' optionname ' is not well formatted']); 159 end 160 end 161 end 162 end 157 163 158 159 160 164 fclose(fid); 165 end %}}} 166 function savemodeljs(self,fid,modelname) % {{{ 161 167 162 163 164 165 166 167 168 169 168 analyses=properties(self); 169 for i=1:numel(analyses), 170 if isempty(fieldnames(self.(analyses{i}))) 171 error(['md.toolkits.' analyses{i} ' is empty']); 172 else 173 writejsstruct(fid,[modelname '.toolkits.' analyses{i}],self.(analyses{i})); 174 end 175 end 170 176 171 172 177 end % }}} 178 end 173 179 end -
../trunk-jpl/src/m/classes/giamme.py
55 55 WriteData(fid, prefix, 'name', 'md.gia.model', 'data', 3, 'format', 'Integer') 56 56 57 57 if isinstance(self.Ngia, list) or self.Ngia.ndim == 1: #list or 1D numpy.ndarray 58 WriteData(fid, prefix, 'data', np.zeros( md.mesh.numberofvertices), 'format', 'DoubleMat', 'mattype', 1, 'name', 'md.gia.Ngia')59 WriteData(fid, prefix, 'data', np.zeros( md.mesh.numberofvertices), 'format', 'DoubleMat', 'mattype', 1, 'name', 'md.gia.Ugia')58 WriteData(fid, prefix, 'data', np.zeros((md.mesh.numberofvertices, 1)), 'format', 'DoubleMat', 'mattype', 1, 'name', 'md.gia.Ngia') 59 WriteData(fid, prefix, 'data', np.zeros((md.mesh.numberofvertices, 1)), 'format', 'DoubleMat', 'mattype', 1, 'name', 'md.gia.Ugia') 60 60 WriteData(fid, prefix, 'data', 1, 'name', 'md.gia.modelid', 'format', 'Double') 61 61 WriteData(fid, prefix, 'name', 'md.gia.nummodels', 'data', 1, 'format', 'Integer') 62 62 else: #2D numpy.ndarray -
../trunk-jpl/src/m/classes/dslmme.py
1 import numpy as np 2 3 from checkfield import checkfield 4 from fielddisplay import fielddisplay 5 from project3d import project3d 6 from WriteData import WriteData 7 8 9 class dslmme(object): 10 ''' 11 DSLMME class definition 12 13 Usage: 14 dsl = dslmme() #dynamic sea level class based on a multi-model ensemble of CMIP5 outputs 15 ''' 16 17 def __init__(self, *args): #{{{ 18 self.modelid = 0 #index into the multi-model ensemble 19 self.global_average_thermosteric_sea_level_change = [] #corresponds to zostoga fields in CMIP5 archives. Specified as a temporally variable global rate (mm/yr) for each ensemble. 20 self.sea_surface_height_change_above_geoid = [] #corresponds to zos fields in CMIP5 archives. Spatial average is 0. Specified as a spatio-temporally variable rate (mm/yr) for each ensemble 21 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 equivalent, not in Pa/yr!) for each ensemble 22 self.compute_fingerprints = 0 #corresponds to zos fields in CMIP5 archives. Spatial average is 0. Specified as a spatio-temporally variable rate (mm/yr) for each ensemble 23 24 nargin = len(args) 25 26 if nargin == 0: 27 self.setdefaultparameters() 28 else: 29 raise Exception('constructor not supported') 30 #}}} 31 32 def __repr__(self): # {{{ 33 s = ' gia mme parameters:\n' 34 s += '{}\n'.format(fielddisplay(self, 'modelid', 'index into the multi-model ensemble, determines which field will be used.')) 35 s += '{}\n'.format(fielddisplay(self, 'Ngia', 'geoid (mm/yr).')) 36 s += '{}\n'.format(fielddisplay(self, 'Ugia', 'uplift (mm/yr).')) 37 38 return s 39 #}}} 40 41 def setdefaultparameters(self): # {{{ 42 return 43 #}}} 44 45 def checkconsistency(self, md, solution, analyses): # {{{ 46 if ('SealevelriseAnalysis' not in analyses) or (solution == 'TransientSolution' and md.transient.isslr == 0): 47 return md 48 49 for i in range(len(self.global_average_thermosteric_sea_level_change)): 50 md = checkfield(md, 'field', self.global_average_thermosteric_sea_level_change[i], 'NaN', 1, 'Inf', 1) 51 md = checkfield(md, 'field', self.sea_surface_height_change_above_geoid[i], 'NaN', 1, 'Inf', 1, 'timeseries', 1) 52 md = checkfield(md, 'field', self.sea_water_pressure_change_at_sea_floor[i], 'NaN', 1, 'Inf', 1, 'timeseries', 1) 53 54 md = checkfield(md, 'field', self.modelid, 'NaN', 1, 'Inf', 1, '>=', 1, '<=',len(self.global_average_thermosteric_sea_level_change)) 55 56 if self.compute_fingerprints: 57 #check geodetic flag of slr is on 58 if md.slr.geodetic==0, 59 raise Exception('DSL checkconsistency error message: if bottom pressure fingerprints computations are requested, slr class should have geodetic flag on') 60 61 return md 62 #}}} 63 64 def marshall(self, prefix, md, fid): #{{{ 65 WriteData(fid, prefix, 'name', 'md.dsl.model', 'data', 2, 'format', 'Integer') 66 WriteData(fid, prefix, 'object', self, 'fieldname', 'compute_fingerprints', 'format', 'Integer') 67 WriteData(fid, prefix, 'object', self, 'fieldname', 'modelid', 'format', 'Integer') 68 WriteData(fid, prefix, 'name', 'md.dsl.nummodels', 'data', len(self.global_average_thermosteric_sea_level_change), 'format', 'Integer') 69 WriteData(fid, prefix, 'object', self, 'fieldname', 'global_average_thermosteric_sea_level_change', 'format', 'MatArray', 'timeseries', 1, 'timeserieslength', 2, 'yts', md.constants.yts, 'scale', 1e-3 / md.constants.yts) 70 WriteData(fid, prefix, 'object', self, 'fieldname', 'sea_water_pressure_change_at_sea_floor', 'format', 'MatArray', 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', md.constants.yts, 'scale', 1e-3 / md.constants.yts) 71 WriteData(fid, prefix, 'object', self, 'fieldname', 'sea_surface_height_change_above_geoid', 'format', 'MatArray', 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', md.constants.yts, 'scale', 1e-3 / md.constants.yts) 72 #}}} 73 74 def extrude(self, md): #{{{ 75 for i in range(len(self.global_average_thermosteric_sea_level_change)): 76 self.sea_surface_height_change_above_geoid[i] = project3d(md, 'vector', self.self.sea_surface_height_change_above_geoid[i], 'type', 'node', 'layer', 1) 77 self.sea_water_pressure_change_at_sea_floor[i] = project3d(md, 'vector', self.sea_water_pressure_change_at_sea_floor[i], 'type', 'node', 'layer', 1) 78 79 return self 80 #}}} -
../trunk-jpl/src/m/classes/geometry.py
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 geometry(object): 9 """10 ''' 10 11 GEOMETRY class definition 11 12 12 Usage:13 geometry = geometry()14 """13 Usage: 14 geometry = geometry() 15 ''' 15 16 16 def __init__(self): #{{{17 self.surface = float('NaN')18 self.thickness = float('NaN')19 self.base = float('NaN')20 self.bed = float('NaN')21 self.hydrostatic_ratio = float('NaN')17 def __init__(self): #{{{ 18 self.surface = np.nan 19 self.thickness = np.nan 20 self.base = np.nan 21 self.bed = np.nan 22 self.hydrostatic_ratio = np.nan 22 23 23 #set defaults24 #set defaults 24 25 self.setdefaultparameters() 25 26 26 #}}} 27 27 28 def __repr__(self): #{{{29 30 s tring = " geometry parameters:"31 s tring = "%s\n%s" % (string, fielddisplay(self, 'surface', 'ice upper surface elevation[m]'))32 s tring = "%s\n%s" % (string, fielddisplay(self, 'thickness', 'ice thickness[m]'))33 s tring = "%s\n%s" % (string, fielddisplay(self, 'base', 'ice baseelevation [m]'))34 string = "%s\n%s" % (string, fielddisplay(self, 'bed', 'bed elevation [m]'))35 return s tring28 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 35 return s 36 36 #}}} 37 37 38 def extrude(self, md): #{{{38 def extrude(self, md): #{{{ 39 39 self.surface = project3d(md, 'vector', self.surface, 'type', 'node') 40 40 self.thickness = project3d(md, 'vector', self.thickness, 'type', 'node') 41 41 self.hydrostatic_ratio = project3d(md, 'vector', self.hydrostatic_ratio, 'type', 'node') … … 44 44 return self 45 45 #}}} 46 46 47 def setdefaultparameters(self): #{{{47 def setdefaultparameters(self): #{{{ 48 48 return self 49 49 #}}} 50 50 51 def checkconsistency(self, md, solution, analyses): #{{{51 def checkconsistency(self, md, solution, analyses): #{{{ 52 52 if (solution == 'TransientSolution' and md.transient.isgia) or (solution == 'GiaSolution'): 53 md = checkfield(md, 'fieldname', 'geometry.thickness', 'NaN', 1, 'Inf', 1, 'timeseries', 1) 53 md = checkfield(md, 'fieldname', 'geometry.thickness', 'timeseries', 1, 'NaN', 1, 'Inf', 1) 54 elif solution == 'SealevelriseSolution': 55 md = checkfield(md, 'fieldname', 'geometry.bed', 'NaN', 1, 'Inf', 1, 'size', [md.mesh.numberofvertices]) 54 56 elif solution == 'LoveSolution': 55 57 return 56 58 else: … … 71 73 return md 72 74 # }}} 73 75 74 def marshall(self, prefix, md, fid): #{{{76 def marshall(self, prefix, md, fid): #{{{ 75 77 WriteData(fid, prefix, 'object', self, 'fieldname', 'surface', 'format', 'DoubleMat', 'mattype', 1) 76 78 WriteData(fid, prefix, 'object', self, 'fieldname', 'thickness', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', md.constants.yts) 77 79 WriteData(fid, prefix, 'object', self, 'fieldname', 'base', 'format', 'DoubleMat', 'mattype', 1) -
../trunk-jpl/src/m/classes/geometry.m
60 60 elseif strcmpi(solution,'LoveSolution'), 61 61 return; 62 62 else 63 md = checkfield(md,'fieldname','geometry.surface' 63 md = checkfield(md,'fieldname','geometry.surface' ,'NaN',1,'Inf',1,'size',[md.mesh.numberofvertices 1]); 64 64 md = checkfield(md,'fieldname','geometry.base' ,'NaN',1,'Inf',1,'size',[md.mesh.numberofvertices 1]); 65 65 md = checkfield(md,'fieldname','geometry.thickness','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices 1],'>',0); 66 66 if any(abs(self.thickness-self.surface+self.base)>10^-9), -
../trunk-jpl/src/m/classes/matice.m
67 67 self.rho_freshwater=1000.; 68 68 69 69 %water viscosity (N.s/m^2) 70 self.mu_water=0.001787; 70 self.mu_water=0.001787; 71 71 72 72 %ice heat capacity cp (J/kg/K) 73 73 self.heatcapacity=2093.; … … 177 177 WriteData(fid,prefix,'object',self,'class','materials','fieldname','rheology_B','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts); 178 178 WriteData(fid,prefix,'object',self,'class','materials','fieldname','rheology_n','format','DoubleMat','mattype',2); 179 179 WriteData(fid,prefix,'data',self.rheology_law,'name','md.materials.rheology_law','format','String'); 180 181 180 WriteData(fid,prefix,'object',self,'class','materials','fieldname','lithosphere_shear_modulus','format','Double'); 182 181 WriteData(fid,prefix,'object',self,'class','materials','fieldname','lithosphere_density','format','Double','scale',10^3); 183 182 WriteData(fid,prefix,'object',self,'class','materials','fieldname','mantle_shear_modulus','format','Double'); -
../trunk-jpl/src/m/classes/dsl.py
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 dsl(object): 9 """10 dsl Class definition10 ''' 11 DSL - slass definition 11 12 12 Usage:13 dsl = dsl()14 """13 Usage: 14 dsl = dsl() 15 ''' 15 16 16 def __init__(self): #{{{17 def __init__(self): #{{{ 17 18 self.global_average_thermosteric_sea_level_change = 0 #corresponds to zostoga field in CMIP5 archives. Specified as a temporally variable global rate (mm/yr) 18 19 self.sea_surface_height_change_above_geoid = float('NaN') #corresponds to zos field in CMIP5 archives. Spatial average is 0. Specified as a spatio-temporally variable rate (mm/yr) 19 20 self.sea_water_pressure_change_at_sea_floor = float('NaN') #corresponds to bpo field in CMIP5 archives. Specified as a spatio-temporally variable rate (in Pa/yr) … … 20 21 self.compute_fingerprints = 0; #do we use the sea water pressure change to compute fingerprints and correct sea_surface_height_change_above_geoid 21 22 #}}} 22 23 23 def __repr__(self): # {{{ 24 string = " dsl parameters:" 25 string = "%s\n%s" % (string, 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 string = "%s\n%s" % (string, 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 string = "%s\n%s" % (string, 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 string = "%s\n%s" % (string, fielddisplay(self, 'compute_fingerprints', 'do we use the sea water pressure change to compute fingerprints and correct sea_surface_height_change_above_geoid')) 29 return string 24 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 31 return s 30 32 #}}} 31 33 32 def extrude(self, md): #{{{34 def extrude(self, md): #{{{ 33 35 self.sea_surface_height_change_above_geoid = project3d(md, 'vector', self.sea_surface_height_change_above_geoid, 'type', 'node') 34 36 self.sea_water_pressure_change_at_sea_floor = project3d(md, 'vector', self.sea_water_pressure_change_at_sea_floor, 'type', 'node') 35 37 return self 36 38 #}}} 37 39 38 def defaultoutputs(self, md): #{{{40 def defaultoutputs(self, md): #{{{ 39 41 return [] 40 42 #}}} 41 43 42 def checkconsistency(self, md, solution, analyses): #{{{44 def checkconsistency(self, md, solution, analyses): #{{{ 43 45 # Early retun 44 if not 'SealevelriseAnalysis'in analyses:46 if 'SealevelriseAnalysis' not in analyses: 45 47 return md 46 48 47 49 if solution == 'TransientSolution' and md.transient.isslr == 0: … … 59 61 return md 60 62 # }}} 61 63 62 def marshall(self, prefix, md, fid): #{{{64 def marshall(self, prefix, md, fid): #{{{ 63 65 yts = md.constants.yts 64 66 WriteData(fid, prefix, 'name', 'md.dsl.model', 'data', 1, 'format', 'Integer') 65 67 WriteData(fid, prefix, 'object', self, 'class', 'dsl', 'fieldname', 'compute_fingerprints', 'format', 'Integer') -
../trunk-jpl/src/m/classes/nodalvalue.py
1 import numpy as np 2 3 from checkfield import checkfield 4 from fielddisplay import fielddisplay 5 from WriteData import WriteData 6 7 8 class dslmme(object): 9 ''' 10 NODALVALUE class definition 11 12 Usage: 13 nodalvalue=nodalvalue() 14 nodalvalue=nodalvalue( 15 'name', 'SealevelriseSNodalValue', 16 'definitionstring', 'Outputdefinition1', 17 'model_string', 'SealevelriseS', 18 'node', 1 19 ) 20 ''' 21 22 def __init__(self, *args): #{{{ 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 retrieved 26 self.node = np.nan #for which node are we retrieving the value? 27 28 #use provided options to change fields 29 options = pairoptions(*args) 30 31 #get name 32 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', '') 36 #}}} 37 38 def __repr__(self): # {{{ 39 s = ' Nodalvalue:\n' 40 s += '{}\n'.format(fielddisplay(self, 'name', 'identifier for this nodalvalue response')) 41 s += '{}\n'.format(fielddisplay(self, 'definitionstring', 'string that identifies this output definition uniquely, from \'Outputdefinition[1-10]\'')) 42 s += '{}\n'.format(fielddisplay(self, 'model_string', 'string for field that is being retrieved')) 43 s += '{}\n'.format(fielddisplay(self, 'node', 'vertex index at which we retrieve the value')) 44 45 return s 46 #}}} 47 48 def setdefaultparameters(self): # {{{ 49 return 50 #}}} 51 52 def checkconsistency(self, md, solution, analyses): # {{{ 53 if not isinstance(self.name, basestring): 54 raise Exception('nodalvalue error message: \'name\' field should be a string!') 55 OutputdefinitionStringArray = [] 56 for i in range(100): 57 OutputdefinitionStringArray[i] = 'Outputdefinition{}'.format(i) 58 md = checkfield(md, 'fieldname', 'self.definitionstring', 'field', self.definitionstring, 'values', OutputdefinitionStringArray) 59 md = checkfield(md, 'fieldname', 'self.node', 'field', self.node, 'values', range(md.mesh.numberofvertices)) 60 61 return md 62 #}}} 63 64 def marshall(self, prefix, md, fid): #{{{ 65 WriteData(fid, prefix, 'data', self.name, 'name', 'md.nodalvalue.name', 'format', 'String') 66 WriteData(fid, prefix, 'data', self.definitionstring, 'name', 'md.nodalvalue.definitionenum', 'format', 'String') 67 WriteData(fid, prefix, 'data', self.model_string, 'name', 'md.nodalvalue.model_enum', 'format', 'String') 68 WriteData(fid, prefix, 'data', self.node, 'name', 'md.nodalvalue.node', 'format', 'Integer') 69 #}}} -
../trunk-jpl/src/m/classes/solidearth.py
23 23 self.sealevel = np.nan 24 24 self.settings = solidearthsettings() 25 25 self.surfaceload = surfaceload() 26 self.love = lovenumbers()26 self.lovenumbers = lovenumbers() 27 27 self.rotational = rotational() 28 28 self.planetradius = planetradius('earth') 29 29 self.requested_outputs = ['default'] … … 64 64 65 65 self.settings.checkconsistency(md, solution, analyses) 66 66 self.surfaceload.checkconsistency(md, solution, analyses) 67 self.love .checkconsistency(md, solution, analyses)67 self.lovenumbers.checkconsistency(md, solution, analyses) 68 68 self.rotational.checkconsistency(md, solution, analyses) 69 69 70 70 return md … … 81 81 82 82 self.settings.marshall(prefix, md, fid) 83 83 self.surfaceload.marshall(prefix, md, fid) 84 self.love .marshall(prefix, md, fid)84 self.lovenumbers.marshall(prefix, md, fid) 85 85 self.rotational.marshall(prefix, md, fid) 86 86 87 87 #process requested outputs -
../trunk-jpl/src/m/classes/toolkits.py
7 7 8 8 9 9 class toolkits(object): 10 """10 ''' 11 11 TOOLKITS class definition 12 12 13 Usage:14 self = toolkits()15 """13 Usage: 14 self = toolkits() 15 ''' 16 16 17 def __init__(self): #{{{17 def __init__(self): #{{{ 18 18 #default toolkits 19 19 if IssmConfig('_HAVE_PETSC_')[0]: 20 20 #MUMPS is the default toolkits … … 33 33 #Use same solver for Recovery mode 34 34 self.RecoveryAnalysis = self.DefaultAnalysis 35 35 36 #The other properties are dynamic37 # 36 #The other properties are dynamic 37 #}}} 38 38 39 def __repr__(self): #{{{39 def __repr__(self): #{{{ 40 40 s = "List of toolkits options per analysis:\n\n" 41 41 for analysis in list(vars(self).keys()): 42 s += " %s\n" % fielddisplay(self, analysis, '')42 s += "{}\n".format(fielddisplay(self, analysis, '')) 43 43 44 45 # 44 return s 45 #}}} 46 46 47 def addoptions(self, analysis, *args): #{{{47 def addoptions(self, analysis, *args): #{{{ 48 48 # Usage example: 49 49 # md.toolkits = addoptions(md.toolkits, 'StressbalanceAnalysis', FSoptions()) 50 50 # md.toolkits = addoptions(md.toolkits, 'StressbalanceAnalysis') … … 58 58 setattr(self, analysis, args[0]) 59 59 60 60 return self 61 # 61 #}}} 62 62 63 def checkconsistency(self, md, solution, analyses): # {{{ 63 def checkconsistency(self, md, solution, analyses): #{{{ 64 # TODO 65 # - Implement something closer to a switch as in 66 # src/m/classes/toolkits.m? 67 # 64 68 for analysis in list(vars(self).keys()): 65 69 if not getattr(self, analysis): 66 md.checkmessage("md.toolkits. %s is empty" % analysis)70 md.checkmessage("md.toolkits.{} is empty".format(analysis)) 67 71 68 72 return md 69 # 73 #}}} 70 74 71 def ToolkitsFile(self, filename): #{{{72 """75 def ToolkitsFile(self, filename): #{{{ 76 ''' 73 77 TOOLKITSFILE - build toolkits file 74 78 75 Build a Petsc compatible options file, from the toolkits model field + return options string 76 This file will also be used when the toolkit used is 'issm' instead of 'petsc' 79 Build a Petsc compatible options file, from the toolkits model 80 field + return options string. 81 This file will also be used when the toolkit used is 'issm' instead 82 of 'petsc'.s 77 83 84 Usage: 85 ToolkitsFile(toolkits, filename) 86 ''' 78 87 79 Usage: ToolkitsFile(toolkits, filename) 80 """ 81 82 #open file for writing 88 #open file for writing 83 89 try: 84 90 fid = open(filename, 'w') 85 91 except IOError as e: 86 92 raise IOError("ToolkitsFile error: could not open {}' for writing due to".format(filename), e) 87 93 88 #write header94 #write header 89 95 fid.write("%s%s%s\n" % ('%Toolkits options file: ', filename, ' written from Python toolkits array')) 90 96 91 #start writing options97 #start writing options 92 98 for analysis in list(vars(self).keys()): 93 99 options = getattr(self, analysis) 94 100 95 #first write analysis:101 #first write analysis: 96 102 fid.write("\n+{}\n".format(analysis)) #append a + to recognize it's an analysis enum 97 #now, write options103 #now, write options 98 104 for optionname, optionvalue in list(options.items()): 99 105 100 106 if not optionvalue: … … 110 116 raise TypeError("ToolkitsFile error: option '{}' is not well formatted.".format(optionname)) 111 117 112 118 fid.close() 113 # 119 #}}} -
../trunk-jpl/src/m/classes/matdamageice.m
119 119 md = checkfield(md,'fieldname','materials.rheology_n','>',0,'size',[md.mesh.numberofelements 1]); 120 120 md = checkfield(md,'fieldname','materials.rheology_law','values',{'None' 'BuddJacka' 'Cuffey' 'CuffeyTemperate' 'Paterson' 'Arrhenius' 'LliboutryDuval'}); 121 121 md = checkfield(md,'fieldname','materials.effectiveconductivity_averaging','numel',[1],'values',[0 1 2]); 122 122 123 123 if ismember('GiaAnalysis',analyses), 124 124 md = checkfield(md,'fieldname','materials.lithosphere_shear_modulus','>',0,'numel',1); 125 125 md = checkfield(md,'fieldname','materials.lithosphere_density','>',0,'numel',1); -
../trunk-jpl/src/m/classes/dslmme.m
14 14 15 15 end 16 16 methods 17 function self = extrude(self,md) % {{{18 for i=1:length(self.global_average_thermosteric_sea_level_change),19 self.sea_surface_height_change_above_geoid{i}=project3d(md,'vector',self.sea_surface_height_change_above_geoid{i},'type','node','layer',1);20 self.sea_water_pressure_change_at_sea_floor{i}=project3d(md,'vector',self.sea_water_pressure_change_at_sea_floor{i},'type','node','layer',1);21 end22 end % }}}23 17 function self = dslmme(varargin) % {{{ 24 18 switch nargin 25 19 case 0 … … 79 73 WriteData(fid,prefix,'object',self,'fieldname','sea_surface_height_change_above_geoid','format','MatArray','timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts,'scale',1e-3/md.constants.yts); 80 74 81 75 end % }}} 76 function self = extrude(self,md) % {{{ 77 for i=1:length(self.global_average_thermosteric_sea_level_change), 78 self.sea_surface_height_change_above_geoid{i}=project3d(md,'vector',self.sea_surface_height_change_above_geoid{i},'type','node','layer',1); 79 self.sea_water_pressure_change_at_sea_floor{i}=project3d(md,'vector',self.sea_water_pressure_change_at_sea_floor{i},'type','node','layer',1); 80 end 81 end % }}} 82 82 function savemodeljs(self,fid,modelname) % {{{ 83 83 84 84 writejsdouble(fid,[modelname '.dsl.modelid'],self.modelid); -
../trunk-jpl/src/m/solve/solve.py
1 1 import datetime 2 2 import os 3 3 import shutil 4 from pairoptions import pairoptions 4 5 5 from ismodelselfconsistent import ismodelselfconsistent 6 from loadresultsfromcluster import loadresultsfromcluster 6 7 from marshall import marshall 8 from pairoptions import pairoptions 9 from preqmu import * 7 10 from waitonlock import waitonlock 8 from loadresultsfromcluster import loadresultsfromcluster9 from preqmu import *10 #from MatlabFuncs import *11 11 12 12 13 13 def solve(md, solutionstring, *args): … … 14 14 ''' 15 15 SOLVE - apply solution sequence for this model 16 16 17 Usage:18 md = solve(md, solutionstring, varargin)19 where varargin is a list of paired arguments of string OR enums17 Usage: 18 md = solve(md, solutionstring, varargin) 19 where varargin is a list of paired arguments of string OR enums 20 20 21 21 solution types available comprise: 22 - 'Stressbalance'or 'sb'23 - 'Masstransport'or 'mt'24 - 'Thermal'or 'th'25 - 'Steadystate'or 'ss'26 - 'Transient'or 'tr'27 - 'Balancethickness'or 'mc'28 - 'Balancevelocity'or 'bv'29 - 'BedSlope'or 'bsl'30 - 'SurfaceSlope'or 'ssl'31 - 'Hydrology'or 'hy'32 - 'DamageEvolution'or 'da'33 - 'Gia'or 'gia'34 - 'Esa'or 'esa'35 - 'Sealevelrise'or 'slr'36 - 'Love'or 'lv'22 - 'Stressbalance' or 'sb' 23 - 'Masstransport' or 'mt' 24 - 'Thermal' or 'th' 25 - 'Steadystate' or 'ss' 26 - 'Transient' or 'tr' 27 - 'Balancethickness' or 'mc' 28 - 'Balancevelocity' or 'bv' 29 - 'BedSlope' or 'bsl' 30 - 'SurfaceSlope' or 'ssl' 31 - 'Hydrology' or 'hy' 32 - 'DamageEvolution' or 'da' 33 - 'Gia' or 'gia' 34 - 'Esa' or 'esa' 35 - 'Sealevelrise' or 'slr' 36 - 'Love' or 'lv' 37 37 38 extra options: 39 - loadonly : does not solve. only load results 40 - checkconsistency : 'yes' or 'no' (default is 'yes'), ensures checks on consistency of model 41 - restart: 'directory name (relative to the execution directory) where the restart file is located. 38 extra options: 39 - loadonly : does not solve. only load results 40 - checkconsistency : 'yes' or 'no' (default is 'yes'), ensures 41 checks on consistency of model 42 - restart : 'directory name (relative to the execution 43 directory) where the restart file is located 42 44 43 Examples:44 md = solve(md, 'Stressbalance')45 md = solve(md, 'sb')45 Examples: 46 md = solve(md, 'Stressbalance') 47 md = solve(md, 'sb') 46 48 ''' 47 49 48 50 #recover and process solve options -
../trunk-jpl/src/m/consistency/checkfield.py
7 7 8 8 9 9 def checkfield(md, *args): 10 """10 ''' 11 11 CHECKFIELD - check field consistency 12 12 13 Used to check model consistency., 14 Requires: 15 'field' or 'fieldname' option. If 'fieldname' is provided, it will retrieve it from the model md. (md.(fieldname)) 16 If 'field' is provided, it will assume the argument following 'field' is a numeric array. 13 Used to check model consistency 14 15 Requires: 16 'field' or 'fieldname' option. If 'fieldname' is provided, it will retrieve it from the model md. (md.(fieldname)) 17 If 'field' is provided, it will assume the argument following 18 'field' is a numeric array. 17 19 18 Available options: 19 - NaN: 1 if check that there is no NaN 20 - size: [lines cols], NaN for non checked dimensions, or 'universal' for any input type (nodal, element, time series, etc) 21 -> : greater than provided value 22 ->= : greater or equal to provided value 23 - < : smallerthan provided value 24 - <=: smaller or equal to provided value 25 - < vec: smallerthan provided values on each vertex 26 - timeseries: 1 if check time series consistency (size and time) 27 - values: cell of strings or vector of acceptable values 28 - numel: list of acceptable number of elements 29 - cell: 1 if check that is cell 30 - empty: 1 if check that non empty 31 - message: overloaded error message 20 Available options: 21 - NaN: 1 if check that there is no NaN 22 - size: [lines cols], NaN for non checked dimensions, or 'universal' 23 for any input type (nodal, element, time series, etc) 24 - > : greater than provided value 25 - >= : greater or equal to provided value 26 - < : smallerthan provided value 27 - <=: smaller or equal to provided value 28 - < vec: smallerthan provided values on each vertex 29 - timeseries: 1 if check time series consistency (size and time) 30 - values: list of acceptable values 31 - numel: list of acceptable number of elements 32 - cell: 1 if check that is cell 33 - empty: 1 if check that non empty 34 - message: overloaded error message 32 35 33 Usage:34 md = checkfield(md, fieldname, options)35 """36 Usage: 37 md = checkfield(md, fieldname, options) 38 ''' 36 39 37 40 #get options 38 41 options = pairoptions(*args) … … 142 145 #check cell 143 146 if options.getfieldvalue('cell', 0): 144 147 if not isinstance(field, (tuple, list, dict)): 145 md = md.checkmessage(options.getfieldvalue('message', "field '{}' should be a cell".format(fieldname)))148 md = md.checkmessage(options.getfieldvalue('message', "field '{}' should be a tuple, list, or dict".format(fieldname))) 146 149 147 150 #check values 148 151 if options.exist('values'): -
../trunk-jpl/test/NightlyRun/test2002.py
38 38 39 39 #mask: {{{ 40 40 mask = gmtmask(md.mesh.lat, md.mesh.long) 41 icemask = np.ones( md.mesh.numberofvertices)41 icemask = np.ones((md.mesh.numberofvertices, 1)) 42 42 pos = np.where(mask == 0)[0] 43 43 icemask[pos] = -1 44 44 pos = np.where(np.sum(mask[md.mesh.elements - 1], axis=1) < 3) … … 47 47 md.mask.ocean_levelset = -icemask 48 48 49 49 #make sure that the ice level set is all inclusive: 50 md.mask.land_levelset = np.zeros((md.mesh.numberofvertices ))51 md.mask.ocean_levelset = -np.ones((md.mesh.numberofvertices ))50 md.mask.land_levelset = np.zeros((md.mesh.numberofvertices, 1)) 51 md.mask.ocean_levelset = -np.ones((md.mesh.numberofvertices, 1)) 52 52 53 53 #make sure that the elements that have loads are fully grounded 54 54 pos = np.nonzero(md.solidearth.surfaceload.icethicknesschange)[0] -
../trunk-jpl/test/NightlyRun/test2002.m
64 64 md.solidearth.settings.maxiter=10; 65 65 66 66 %eustatic run: 67 md.solidearth.settings.rigid=0; md.solidearth.settings.elastic=0;md.solidearth.settings.rotation=0; 67 md.solidearth.settings.rigid=0; 68 md.solidearth.settings.elastic=0; 69 md.solidearth.settings.rotation=0; 68 70 md=solve(md,'Sealevelrise'); 69 71 Seustatic=md.results.SealevelriseSolution.Sealevel; 70 72 -
../trunk-jpl/src/m/classes/matice.py
1 import numpy as np 2 1 3 from fielddisplay import fielddisplay 2 4 from project3d import project3d 3 5 from checkfield import checkfield … … 5 7 6 8 7 9 class matice(object): 8 """10 ''' 9 11 MATICE class definition 10 12 11 12 matice = matice()13 """13 Usage: 14 matice = matice() 15 ''' 14 16 15 def __init__(self): #{{{17 def __init__(self): #{{{ 16 18 self.rho_ice = 0. 17 19 self.rho_water = 0. 18 20 self.rho_freshwater = 0. … … 26 28 self.beta = 0. 27 29 self.mixed_layer_capacity = 0. 28 30 self.thermal_exchange_velocity = 0. 29 self.rheology_B = float('NaN')30 self.rheology_n = float('NaN')31 self.rheology_B = np.nan 32 self.rheology_n = np.nan 31 33 self.rheology_law = '' 32 34 33 #giaivins :35 #giaivins 34 36 self.lithosphere_shear_modulus = 0. 35 37 self.lithosphere_density = 0. 36 38 self.mantle_shear_modulus = 0. 37 39 self.mantle_density = 0. 38 40 39 # SLR40 self.earth_density = 551241 #slr 42 self.earth_density = 0 41 43 self.setdefaultparameters() 42 44 #}}} 43 45 44 def __repr__(self): # {{{ 45 string = " Materials:" 46 def __repr__(self): #{{{ 47 s = " Materials:" 48 s = "%s\n%s" % (s, fielddisplay(self, "rho_ice", "ice density [kg/m^3]")) 49 s = "%s\n%s" % (s, fielddisplay(self, "rho_water", "water density [kg/m^3]")) 50 s = "%s\n%s" % (s, fielddisplay(self, "rho_freshwater", "fresh water density [kg/m^3]")) 51 s = "%s\n%s" % (s, fielddisplay(self, "mu_water", "water viscosity [Ns/m^2]")) 52 s = "%s\n%s" % (s, fielddisplay(self, "heatcapacity", "heat capacity [J/kg/K]")) 53 s = "%s\n%s" % (s, fielddisplay(self, "thermalconductivity", "ice thermal conductivity [W/m/K]")) 54 s = "%s\n%s" % (s, fielddisplay(self, "temperateiceconductivity", "temperate ice thermal conductivity [W/m/K]")) 55 s = "%s\n%s" % (s, fielddisplay(self, "effectiveconductivity_averaging", "computation of effectiveconductivity: (0) arithmetic mean, (1) harmonic mean, (2) geometric mean (default)")) 56 s = "%s\n%s" % (s, fielddisplay(self, "meltingpoint", "melting point of ice at 1atm in K")) 57 s = "%s\n%s" % (s, fielddisplay(self, "latentheat", "latent heat of fusion [J/m^3]")) 58 s = "%s\n%s" % (s, fielddisplay(self, "beta", "rate of change of melting point with pressure [K/Pa]")) 59 s = "%s\n%s" % (s, fielddisplay(self, "mixed_layer_capacity", "mixed layer capacity [W/kg/K]")) 60 s = "%s\n%s" % (s, fielddisplay(self, "thermal_exchange_velocity", "thermal exchange velocity [m/s]")) 61 s = "%s\n%s" % (s, fielddisplay(self, "rheology_B", "flow law parameter [Pa s^(1/n)]")) 62 s = "%s\n%s" % (s, fielddisplay(self, "rheology_n", "Glen's flow law exponent")) 63 s = "%s\n%s" % (s, fielddisplay(self, "rheology_law", "law for the temperature dependance of the rheology: 'None', 'BuddJacka', 'Cuffey', 'CuffeyTemperate', 'Paterson', 'Arrhenius', 'LliboutryDuval', 'NyeCO2', or 'NyeH2O'")) 64 s = "%s\n%s" % (s, fielddisplay(self, "lithosphere_shear_modulus", "Lithosphere shear modulus [Pa]")) 65 s = "%s\n%s" % (s, fielddisplay(self, "lithosphere_density", "Lithosphere density [g/cm^-3]")) 66 s = "%s\n%s" % (s, fielddisplay(self, "mantle_shear_modulus", "Mantle shear modulus [Pa]")) 67 s = "%s\n%s" % (s, fielddisplay(self, "mantle_density", "Mantle density [g/cm^-3]")) 68 s = "%s\n%s" % (s, fielddisplay(self, "earth_density", "Mantle density [kg/m^-3]")) 46 69 47 string = "%s\n%s" % (string, fielddisplay(self, "rho_ice", "ice density [kg / m^3]")) 48 string = "%s\n%s" % (string, fielddisplay(self, "rho_water", "water density [kg / m^3]")) 49 string = "%s\n%s" % (string, fielddisplay(self, "rho_freshwater", "fresh water density [kg / m^3]")) 50 string = "%s\n%s" % (string, fielddisplay(self, "mu_water", "water viscosity [N s / m^2]")) 51 string = "%s\n%s" % (string, fielddisplay(self, "heatcapacity", "heat capacity [J / kg / K]")) 52 string = "%s\n%s" % (string, fielddisplay(self, "thermalconductivity", "ice thermal conductivity [W / m / K]")) 53 string = "%s\n%s" % (string, fielddisplay(self, "temperateiceconductivity", "temperate ice thermal conductivity [W / m / K]")) 54 string = "%s\n%s" % (string, fielddisplay(self, "effectiveconductivity_averaging", "computation of effectiveconductivity: (0) arithmetic mean, (1) harmonic mean, (2) geometric mean (default)")) 55 string = "%s\n%s" % (string, fielddisplay(self, "meltingpoint", "melting point of ice at 1atm in K")) 56 string = "%s\n%s" % (string, fielddisplay(self, "latentheat", "latent heat of fusion [J / m^3]")) 57 string = "%s\n%s" % (string, fielddisplay(self, "beta", "rate of change of melting point with pressure [K / Pa]")) 58 string = "%s\n%s" % (string, fielddisplay(self, "mixed_layer_capacity", "mixed layer capacity [W / kg / K]")) 59 string = "%s\n%s" % (string, fielddisplay(self, "thermal_exchange_velocity", "thermal exchange velocity [m / s]")) 60 string = "%s\n%s" % (string, fielddisplay(self, "rheology_B", "flow law parameter [Pa s^(1 / n)]")) 61 string = "%s\n%s" % (string, fielddisplay(self, "rheology_n", "Glen's flow law exponent")) 62 string = "%s\n%s" % (string, fielddisplay(self, "rheology_law", "law for the temperature dependance of the rheology: 'None', 'BuddJacka', 'Cuffey', 'CuffeyTemperate', 'Paterson', 'Arrhenius', 'LliboutryDuval', 'NyeCO2', or 'NyeH2O'")) 63 string = "%s\n%s" % (string, fielddisplay(self, "lithosphere_shear_modulus", "Lithosphere shear modulus [Pa]")) 64 string = "%s\n%s" % (string, fielddisplay(self, "lithosphere_density", "Lithosphere density [g / cm^ - 3]")) 65 string = "%s\n%s" % (string, fielddisplay(self, "mantle_shear_modulus", "Mantle shear modulus [Pa]")) 66 string = "%s\n%s" % (string, fielddisplay(self, "mantle_density", "Mantle density [g / cm^ - 3]")) 67 string = "%s\n%s" % (string, fielddisplay(self, "earth_density", "Mantle density [kg / m^ - 3]")) 68 return string 70 return s 69 71 #}}} 70 72 71 def extrude(self, md): #{{{73 def extrude(self, md): #{{{ 72 74 self.rheology_B = project3d(md, 'vector', self.rheology_B, 'type', 'node') 73 75 self.rheology_n = project3d(md, 'vector', self.rheology_n, 'type', 'element') 74 76 return self 75 77 #}}} 76 78 77 def setdefaultparameters(self): #{{{78 #ice density (kg /m^3)79 def setdefaultparameters(self): #{{{ 80 #ice density (kg/m^3) 79 81 self.rho_ice = 917. 80 #ocean water density (kg /m^3)82 #ocean water density (kg/m^3) 81 83 self.rho_water = 1023. 82 #fresh water density (kg /m^3)84 #fresh water density (kg/m^3) 83 85 self.rho_freshwater = 1000. 84 #water viscosity (N.s /m^2)86 #water viscosity (N.s/m^2) 85 87 self.mu_water = 0.001787 86 #ice heat capacity cp (J / kg /K)88 #ice heat capacity cp (J/kg/K) 87 89 self.heatcapacity = 2093. 88 #ice latent heat of fusion L (J /kg)90 #ice latent heat of fusion L (J/kg) 89 91 self.latentheat = 3.34e5 90 #ice thermal conductivity (W / m /K)92 #ice thermal conductivity (W/m/K) 91 93 self.thermalconductivity = 2.4 94 #temperate ice thermal conductivity (W/m/K) 95 self.temperateiceconductivity = 0.24 92 96 #computation of effective conductivity 93 97 self.effectiveconductivity_averaging = 1 94 #temperate ice thermal conductivity (W / m / K)95 self.temperateiceconductivity = 0.2496 98 #the melting point of ice at 1 atmosphere of pressure in K 97 99 self.meltingpoint = 273.15 98 #rate of change of melting point with pressure (K /Pa)100 #rate of change of melting point with pressure (K/Pa) 99 101 self.beta = 9.8e-8 100 #mixed layer (ice-water interface) heat capacity (J / kg /K)102 #mixed layer (ice-water interface) heat capacity (J/kg/K) 101 103 self.mixed_layer_capacity = 3974. 102 #thermal exchange velocity (ice-water interface) (m /s)104 #thermal exchange velocity (ice-water interface) (m/s) 103 105 self.thermal_exchange_velocity = 1.00e-4 104 106 #Rheology law: what is the temperature dependence of B with T 105 107 #available: none, paterson and arrhenius … … 106 108 self.rheology_law = 'Paterson' 107 109 108 110 # GIA: 109 self.lithosphere_shear_modulus = 6.7e10 110 self.lithosphere_density = 3.32 # (g / cm^ -3)111 self.lithosphere_shear_modulus = 6.7e10 # (Pa) 112 self.lithosphere_density = 3.32 # (g/cm^-3) 111 113 self.mantle_shear_modulus = 1.45e11 # (Pa) 112 self.mantle_density = 3.34 # (g / cm^ -3)114 self.mantle_density = 3.34 # (g/cm^-3) 113 115 114 #SLR 115 self.earth_density = 5512 # average density of the Earth, (kg / m^3) 116 return self 116 # SLR 117 self.earth_density = 5512 # average density of the Earth, (kg/m^3) 117 118 #}}} 118 119 119 def checkconsistency(self, md, solution, analyses): # {{{ 120 md = checkfield(md, 'fieldname', 'materials.rho_ice', '>', 0) 121 md = checkfield(md, 'fieldname', 'materials.rho_water', '>', 0) 122 md = checkfield(md, 'fieldname', 'materials.rho_freshwater', '>', 0) 123 md = checkfield(md, 'fieldname', 'materials.mu_water', '>', 0) 124 md = checkfield(md, 'fieldname', 'materials.rheology_B', '>', 0, 'timeseries', 1, 'NaN', 1, 'Inf', 1) 125 md = checkfield(md, 'fieldname', 'materials.rheology_n', '>', 0, 'size', [md.mesh.numberofelements]) 126 md = checkfield(md, 'fieldname', 'materials.rheology_law', 'values', ['None', 'BuddJacka', 'Cuffey', 'CuffeyTemperate', 'Paterson', 'Arrhenius', 'LliboutryDuval', 'NyeCO2', 'NyeH2O']) 127 md = checkfield(md, 'fieldname', 'materials.effectiveconductivity_averaging', 'numel', [1], 'values', [0, 1, 2]) 128 md = checkfield(md, 'fieldname', 'materials.lithosphere_shear_modulus', '>', 0, 'numel', [1]) 129 md = checkfield(md, 'fieldname', 'materials.lithosphere_density', '>', 0, 'numel', [1]) 130 md = checkfield(md, 'fieldname', 'materials.mantle_shear_modulus', '>', 0, 'numel', [1]) 131 md = checkfield(md, 'fieldname', 'materials.mantle_density', '>', 0, 'numel', [1]) 132 md = checkfield(md, 'fieldname', 'materials.earth_density', '>', 0, 'numel', [1]) 120 def checkconsistency(self, md, solution, analyses): #{{{ 121 if solution != 'SealevelriseSolution': 122 md = checkfield(md, 'fieldname', 'materials.rho_ice', '>', 0) 123 md = checkfield(md, 'fieldname', 'materials.rho_water', '>', 0) 124 md = checkfield(md, 'fieldname', 'materials.rho_freshwater', '>', 0) 125 md = checkfield(md, 'fieldname', 'materials.mu_water', '>', 0) 126 md = checkfield(md, 'fieldname', 'materials.rheology_B', '>', 0, 'timeseries', 1, 'NaN', 1, 'Inf', 1) 127 md = checkfield(md, 'fieldname', 'materials.rheology_n', '>', 0, 'size', [md.mesh.numberofelements]) 128 md = checkfield(md, 'fieldname', 'materials.rheology_law', 'values', ['None', 'BuddJacka', 'Cuffey', 'CuffeyTemperate', 'Paterson', 'Arrhenius', 'LliboutryDuval', 'NyeCO2', 'NyeH2O']) 129 md = checkfield(md, 'fieldname', 'materials.effectiveconductivity_averaging', 'numel', [1], 'values', [0, 1, 2]) 130 131 if 'GiaAnalysis' in analyses: 132 md = checkfield(md, 'fieldname', 'materials.lithosphere_shear_modulus', '>', 0, 'numel', [1]) 133 md = checkfield(md, 'fieldname', 'materials.lithosphere_density', '>', 0, 'numel', [1]) 134 md = checkfield(md, 'fieldname', 'materials.mantle_shear_modulus', '>', 0, 'numel', [1]) 135 md = checkfield(md, 'fieldname', 'materials.mantle_density', '>', 0, 'numel', [1]) 136 137 if 'SealevelriseAnalysis' in analyses: 138 md = checkfield(md, 'fieldname', 'materials.earth_density', '>', 0, 'numel', [1]) 139 133 140 return md 134 # 141 #}}} 135 142 136 def marshall(self, prefix, md, fid): #{{{143 def marshall(self, prefix, md, fid): #{{{ 137 144 WriteData(fid, prefix, 'name', 'md.materials.type', 'data', 3, 'format', 'Integer') 138 145 WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'rho_ice', 'format', 'Double') 139 146 WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'rho_water', 'format', 'Double') … … 150 157 WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'thermal_exchange_velocity', 'format', 'Double') 151 158 WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'rheology_B', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', md.constants.yts) 152 159 WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'rheology_n', 'format', 'DoubleMat', 'mattype', 2) 153 WriteData(fid, prefix, 'data', self.rheology_law, 'name', 'md.materials.rheology_law', 'format', 'String') 154 160 WriteData(fid, prefix, 'data', self.rheology_law, 'name', 'md.materials.rheology_law', 'format', 's') 155 161 WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'lithosphere_shear_modulus', 'format', 'Double') 156 162 WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'lithosphere_density', 'format', 'Double', 'scale', 10.**3.) 157 163 WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'mantle_shear_modulus', 'format', 'Double') 158 164 WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'mantle_density', 'format', 'Double', 'scale', 10.**3.) 159 165 WriteData(fid, prefix, 'object', self, 'class', 'materials', 'fieldname', 'earth_density', 'format', 'Double') 160 161 # }}} 166 #}}} -
../trunk-jpl/src/m/classes/slr.py
49 49 #}}} 50 50 51 51 def __repr__(self): # {{{ 52 s tring= ' slr parameters:'53 s tring = "%s\n%s" % (string, fielddisplay(self, 'deltathickness', 'thickness change: ice height equivalent [m]'))54 s tring = "%s\n%s" % (string, fielddisplay(self, 'sealevel', 'current sea level (prior to computation) [m]'))55 s tring = "%s\n%s" % (string, fielddisplay(self, 'spcthickness', 'thickness constraints (NaN means no constraint) [m]'))56 s tring = "%s\n%s" % (string, fielddisplay(self, 'reltol', 'sea level rise relative convergence criterion, (NaN: not applied)'))57 s tring = "%s\n%s" % (string, fielddisplay(self, 'abstol', 'sea level rise absolute convergence criterion, (default, NaN: not applied)'))58 s tring = "%s\n%s" % (string, fielddisplay(self, 'maxiter', 'maximum number of nonlinear iterations'))59 s tring = "%s\n%s" % (string, fielddisplay(self, 'love_h', 'load Love number for radial displacement'))60 s tring = "%s\n%s" % (string, fielddisplay(self, 'love_k', 'load Love number for gravitational potential perturbation'))61 s tring = "%s\n%s" % (string, fielddisplay(self, 'love_l', 'load Love number for horizontal displaements'))62 s tring = "%s\n%s" % (string, fielddisplay(self, 'tide_love_k', 'tidal load Love number (degree 2)'))63 s tring = "%s\n%s" % (string, fielddisplay(self, 'tide_love_h', 'tidal load Love number (degree 2)'))64 s tring = "%s\n%s" % (string, fielddisplay(self, 'fluid_love', 'secular fluid Love number'))65 s tring = "%s\n%s" % (string, fielddisplay(self, 'equatorial_moi', 'mean equatorial moment of inertia [kg m^2]'))66 s tring = "%s\n%s" % (string, fielddisplay(self, 'polar_moi', 'polar moment of inertia [kg m^2]'))67 s tring = "%s\n%s" % (string, fielddisplay(self, 'angular_velocity', 'mean rotational velocity of earth [per second]'))68 s tring = "%s\n%s" % (string, fielddisplay(self, 'ocean_area_scaling', 'correction for model representation of ocean area [default: No correction]'))69 s tring = "%s\n%s" % (string, fielddisplay(self, 'hydro_rate', 'rate of hydrological expansion [mm / yr]'))70 s tring = "%s\n%s" % (string, fielddisplay(self, 'geodetic', 'compute geodetic SLR? (in addition to steric?) default 0'))71 s tring = "%s\n%s" % (string, fielddisplay(self, 'geodetic_run_frequency', 'how many time steps we skip before we run SLR solver during transient (default: 1)'))72 s tring = "%s\n%s" % (string, fielddisplay(self, 'rigid', 'rigid earth graviational potential perturbation'))73 s tring = "%s\n%s" % (string, fielddisplay(self, 'elastic', 'elastic earth graviational potential perturbation'))74 s tring = "%s\n%s" % (string, fielddisplay(self, 'rotation', 'earth rotational potential perturbation'))75 s tring = "%s\n%s" % (string, fielddisplay(self, 'degacc', 'accuracy (default .01 deg) for numerical discretization of the Green''s functions'))76 s tring = "%s\n%s" % (string, fielddisplay(self, 'transitions', 'indices into parts of the mesh that will be icecaps'))77 s tring = "%s\n%s" % (string, fielddisplay(self, 'requested_outputs', 'additional outputs requested'))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 78 79 return s tring79 return s 80 80 # }}} 81 81 82 82 def setdefaultparameters(self): # {{{ … … 142 142 md = checkfield(md, 'fieldname', 'slr.geodetic_run_frequency', 'size', [1, 1], '>=', 1) 143 143 md = checkfield(md, 'fieldname', 'slr.hydro_rate', 'NaN', 1, 'Inf', 1, 'size', [md.mesh.numberofvertices]) 144 144 md = checkfield(md, 'fieldname', 'slr.degacc', 'size', [1, 1], '>=', 1e-10) 145 md = checkfield(md, 'fieldname', 'slr.requested_outputs', 's tringrow', 1)145 md = checkfield(md, 'fieldname', 'slr.requested_outputs', 'srow', 1) 146 146 md = checkfield(md, 'fieldname', 'slr.horiz', 'NaN', 1, 'Inf', 1, 'values', [0, 1]) 147 147 148 148 #check that love numbers are provided at the same level of accuracy: … … 201 201 if len(indices) > 0: 202 202 outputscopy = outputs[0:max(0, indices[0] - 1)] + self.defaultoutputs(md) + outputs[indices[0] + 1:] 203 203 outputs = outputscopy 204 WriteData(fid, prefix, 'data', outputs, 'name', 'md.slr.requested_outputs', 'format', ' StringArray')204 WriteData(fid, prefix, 'data', outputs, 'name', 'md.slr.requested_outputs', 'format', 'sArray') 205 205 # }}}
Note:
See TracBrowser
for help on using the repository browser.