[9621] | 1 | %CONSTANTS class definition
|
---|
[9599] | 2 | %
|
---|
| 3 | % Usage:
|
---|
[9621] | 4 | % constants=constants();
|
---|
[9599] | 5 |
|
---|
[9621] | 6 | classdef constants
|
---|
[9599] | 7 | properties (SetAccess=public)
|
---|
[26744] | 8 | g = 0.;
|
---|
| 9 | omega = 0.;
|
---|
| 10 | yts = 0.;
|
---|
| 11 | referencetemperature = 0.;
|
---|
| 12 | gravitational_constant = 0.;
|
---|
[9599] | 13 | end
|
---|
| 14 | methods
|
---|
[19105] | 15 | function self = constants(varargin) % {{{
|
---|
[9599] | 16 | switch nargin
|
---|
| 17 | case 0
|
---|
[19105] | 18 | self=setdefaultparameters(self);
|
---|
[9599] | 19 | otherwise
|
---|
| 20 | error('constructor not supported');
|
---|
| 21 | end
|
---|
| 22 | end % }}}
|
---|
[19105] | 23 | function self = setdefaultparameters(self) % {{{
|
---|
[9599] | 24 |
|
---|
[9621] | 25 | %acceleration due to gravity (m/s^2)
|
---|
[19105] | 26 | self.g=9.81;
|
---|
[9621] | 27 |
|
---|
[19105] | 28 | %Earth's rotation speed
|
---|
| 29 | self.omega = 7.292*1e-5;
|
---|
| 30 |
|
---|
[9621] | 31 | %converstion from year to seconds
|
---|
[21341] | 32 | self.yts=365.*24.*3600.;
|
---|
[9621] | 33 |
|
---|
| 34 | %the reference temperature for enthalpy model (cf Aschwanden)
|
---|
[19105] | 35 | self.referencetemperature=223.15;
|
---|
[26744] | 36 |
|
---|
| 37 | %gravitational constant:
|
---|
| 38 | self.gravitational_constant = 6.67259e-11;
|
---|
[9621] | 39 |
|
---|
[9599] | 40 | end % }}}
|
---|
[19105] | 41 | function md = checkconsistency(self,md,solution,analyses) % {{{
|
---|
[9730] | 42 |
|
---|
[19105] | 43 | md = checkfield(md,'fieldname','constants.g','>=',0,'size',[1 1]); %We allow 0 for validation tests
|
---|
| 44 | md = checkfield(md,'fieldname','constants.omega','>=',0,'size',[1 1]);
|
---|
[17806] | 45 | md = checkfield(md,'fieldname','constants.yts','>',0,'size',[1 1]);
|
---|
| 46 | md = checkfield(md,'fieldname','constants.referencetemperature','size',[1 1]);
|
---|
[26744] | 47 | md = checkfield(md,'fieldname','constants.gravitational_constant','size',[1 1]);
|
---|
[9749] | 48 |
|
---|
[9730] | 49 | end % }}}
|
---|
[19105] | 50 | function disp(self) % {{{
|
---|
[9799] | 51 | disp(sprintf(' constants parameters:'));
|
---|
| 52 |
|
---|
[19105] | 53 | fielddisplay(self,'g','gravitational acceleration [m/s^2]');
|
---|
| 54 | fielddisplay(self,'omega','angular velocity of Earth [rad/s]');
|
---|
| 55 | fielddisplay(self,'yts','number of seconds in a year [s/yr]');
|
---|
| 56 | fielddisplay(self,'referencetemperature','reference temperature used in the enthalpy model [K]');
|
---|
[26744] | 57 | fielddisplay(self,'gravitational_constant','Newtonian constant of gravitation [m^3/kg/s^2]');
|
---|
[9799] | 58 |
|
---|
| 59 | end % }}}
|
---|
[21341] | 60 | function marshall(self,prefix,md,fid) % {{{
|
---|
| 61 | WriteData(fid,prefix,'object',self,'fieldname','g','format','Double');
|
---|
| 62 | WriteData(fid,prefix,'object',self,'fieldname','yts','format','Double');
|
---|
| 63 | WriteData(fid,prefix,'object',self,'fieldname','referencetemperature','format','Double');
|
---|
[26744] | 64 | WriteData(fid,prefix,'object',self,'fieldname','gravitational_constant','format','Double');
|
---|
[10981] | 65 | end % }}}
|
---|
[20500] | 66 | function savemodeljs(self,fid,modelname) % {{{
|
---|
| 67 |
|
---|
| 68 | writejsdouble(fid,[modelname '.constants.g'],self.g);
|
---|
| 69 | writejsdouble(fid,[modelname '.constants.omega'],self.omega);
|
---|
| 70 | writejsdouble(fid,[modelname '.constants.yts'],self.yts);
|
---|
| 71 | writejsdouble(fid,[modelname '.constants.referencetemperature'],self.referencetemperature);
|
---|
[26744] | 72 | writejsdouble(fid,[modelname '.constants.gravitational_constant'],self.gravitational_constant);
|
---|
[20500] | 73 |
|
---|
| 74 | end % }}}
|
---|
[9599] | 75 | end
|
---|
| 76 | end
|
---|