[9621] | 1 | %CONSTANTS class definition
|
---|
[9599] | 2 | %
|
---|
| 3 | % Usage:
|
---|
[9621] | 4 | % constants=constants();
|
---|
[9599] | 5 |
|
---|
[9621] | 6 | classdef constants
|
---|
[9599] | 7 | properties (SetAccess=public)
|
---|
[10981] | 8 | g = 0;
|
---|
| 9 | yts = 0;
|
---|
| 10 | referencetemperature = 0;
|
---|
[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 |
|
---|
[9621] | 30 | %acceleration due to gravity (m/s^2)
|
---|
| 31 | obj.g=9.81;
|
---|
| 32 |
|
---|
| 33 | %converstion from year to seconds
|
---|
| 34 | obj.yts=365*24*3600;
|
---|
| 35 |
|
---|
| 36 | %the reference temperature for enthalpy model (cf Aschwanden)
|
---|
| 37 | obj.referencetemperature=223.15;
|
---|
| 38 |
|
---|
[9599] | 39 | end % }}}
|
---|
[9853] | 40 | function flag = checkconsistency(obj,md,solution,analyses) % {{{
|
---|
[9730] | 41 |
|
---|
[9860] | 42 | checkfield(md,'constants.g','>',0,'size',[1 1]);
|
---|
| 43 | checkfield(md,'constants.yts','>',0,'size',[1 1]);
|
---|
| 44 | checkfield(md,'constants.referencetemperature','size',[1 1]);
|
---|
[9749] | 45 |
|
---|
[9730] | 46 | end % }}}
|
---|
[9799] | 47 | function disp(obj) % {{{
|
---|
| 48 | disp(sprintf(' constants parameters:'));
|
---|
| 49 |
|
---|
| 50 | fielddisplay(obj,'g','gravitational acceleration');
|
---|
| 51 | fielddisplay(obj,'yts','number of secongs in a year');
|
---|
| 52 | fielddisplay(obj,'referencetemperature','reference temperature used in the enthalpy model');
|
---|
| 53 |
|
---|
| 54 | end % }}}
|
---|
[10981] | 55 | function marshall(obj,fid) % {{{
|
---|
| 56 | WriteData(fid,'object',obj,'fieldname','g','format','Double');
|
---|
| 57 | WriteData(fid,'object',obj,'fieldname','yts','format','Double');
|
---|
| 58 | WriteData(fid,'object',obj,'fieldname','referencetemperature','format','Double');
|
---|
| 59 | end % }}}
|
---|
[9599] | 60 | end
|
---|
| 61 | end
|
---|