| 1 | %CONSTANTS class definition
|
|---|
| 2 | %
|
|---|
| 3 | % Usage:
|
|---|
| 4 | % constants=constants();
|
|---|
| 5 |
|
|---|
| 6 | classdef constants
|
|---|
| 7 | properties (SetAccess=public)
|
|---|
| 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');
|
|---|
| 11 | end
|
|---|
| 12 | methods
|
|---|
| 13 | function obj = constants(varargin) % {{{
|
|---|
| 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
|
|---|
| 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 |
|
|---|
| 46 | end % }}}
|
|---|
| 47 | function flag = checkconsistency(obj,md,solution,analyses) % {{{
|
|---|
| 48 |
|
|---|
| 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]);
|
|---|
| 52 |
|
|---|
| 53 | end % }}}
|
|---|
| 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 % }}}
|
|---|
| 62 | end
|
|---|
| 63 | end
|
|---|