[9621] | 1 | %CONSTANTS class definition
|
---|
[9599] | 2 | %
|
---|
| 3 | % Usage:
|
---|
[9621] | 4 | % constants=constants();
|
---|
[9599] | 5 |
|
---|
[9621] | 6 | classdef constants
|
---|
[9599] | 7 | properties (SetAccess=public)
|
---|
[9621] | 8 | g = modelfield('default',0,'marshall',true,'format','Double');
|
---|
| 9 | yts = modelfield('default',0,'marshall',true,'format','Double');
|
---|
| 10 | referencetemperature = modelfield('default',0,'marshall',true,'format','Double');
|
---|
[9599] | 11 | end
|
---|
| 12 | methods
|
---|
[9621] | 13 | function obj = constants(varargin) % {{{
|
---|
[9599] | 14 | switch nargin
|
---|
| 15 | case 0
|
---|
| 16 | obj=setdefaultparameters(obj);
|
---|
| 17 | case 1
|
---|
| 18 | in=varargin{1};
|
---|
| 19 | if (isa(in,'numeric') & in==0),
|
---|
| 20 | % requesting templates do nothing
|
---|
| 21 | else
|
---|
| 22 | error('constructor not supported');
|
---|
| 23 | end
|
---|
| 24 | otherwise
|
---|
| 25 | error('constructor not supported');
|
---|
| 26 | end
|
---|
| 27 | end % }}}
|
---|
| 28 | function obj = setdefaultparameters(obj) % {{{
|
---|
| 29 |
|
---|
| 30 | %first, use the defaults provided by the properties definition above.
|
---|
| 31 | fieldnames=fields(obj);
|
---|
| 32 | for i=1:length(fieldnames),
|
---|
| 33 | fieldname=fieldnames{i};
|
---|
| 34 | obj.(fieldname)=obj.(fieldname).default;
|
---|
| 35 | end
|
---|
[9621] | 36 |
|
---|
| 37 | %acceleration due to gravity (m/s^2)
|
---|
| 38 | obj.g=9.81;
|
---|
| 39 |
|
---|
| 40 | %converstion from year to seconds
|
---|
| 41 | obj.yts=365*24*3600;
|
---|
| 42 |
|
---|
| 43 | %the reference temperature for enthalpy model (cf Aschwanden)
|
---|
| 44 | obj.referencetemperature=223.15;
|
---|
| 45 |
|
---|
[9599] | 46 | end % }}}
|
---|
[9853] | 47 | function flag = checkconsistency(obj,md,solution,analyses) % {{{
|
---|
[9730] | 48 |
|
---|
[9860] | 49 | checkfield(md,'constants.g','>',0,'size',[1 1]);
|
---|
| 50 | checkfield(md,'constants.yts','>',0,'size',[1 1]);
|
---|
| 51 | checkfield(md,'constants.referencetemperature','size',[1 1]);
|
---|
[9749] | 52 |
|
---|
[9730] | 53 | end % }}}
|
---|
[9799] | 54 | function disp(obj) % {{{
|
---|
| 55 | disp(sprintf(' constants parameters:'));
|
---|
| 56 |
|
---|
| 57 | fielddisplay(obj,'g','gravitational acceleration');
|
---|
| 58 | fielddisplay(obj,'yts','number of secongs in a year');
|
---|
| 59 | fielddisplay(obj,'referencetemperature','reference temperature used in the enthalpy model');
|
---|
| 60 |
|
---|
| 61 | end % }}}
|
---|
[9599] | 62 | end
|
---|
| 63 | end
|
---|