source: issm/trunk/src/m/classes/constants.m@ 9860

Last change on this file since 9860 was 9860, checked in by Mathieu Morlighem, 13 years ago

Better and simpler consistency checks

File size: 1.8 KB
Line 
1%CONSTANTS class definition
2%
3% Usage:
4% constants=constants();
5
6classdef 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
63end
Note: See TracBrowser for help on using the repository browser.