205: An internal constructor for 'Model_14' objects not...

Description Arguments Details Author(s) Examples

Description

This method implements R's initialize generic for objects of class Model_14 and is not intended as part of the public interface to SoilR. It may change in the future as the classes implementing SoilR may. It is called whenever a new object of this class is created by a call to new with the first argument Model_14. It performs some sanity checks of its arguments and in case those tests pass returns an object of class Model_14 The checks can be turned off.( see arguments)

Arguments

.Object

the Model_14 object itself

times

The points in time where the solution is sought

mat

A decomposition Operator of some kind

initialValues
initialValF

An object of class ConstFc containing a vector with the initial values of the radiocarbon fraction for each pool and a format string describing in which format the values are given.

inputFluxes
c14Fraction
c14DecayRate
solverfunc
pass

Details

Due to the mechanism of S4 object initialization (package "methods") new always calls initialize. (see the help pages for initialize and initialize-methods for details)

Author(s)

Carlos A. Sierra <csierra@bgc-jena.mpg.de>, Markus Mueller <mamueller@bgc-jena.mpg.de>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
require(RUnit)
# We present three possible scenarios:
# 1.) create an object from valid input
# 2.) try to build an Model_14 object with unsound parameters and 
#     show the savety net in action.
# 3.) force an unsound model to be created that would be rejected by default

#1.)
	# create the ingredients and assemble them to a Model_14  in the final step 
	t_start=1960
	t_end=2010
	tn=220
	timestep=(t_end-t_start)/tn 
	## the time 
	t=seq(t_start,t_end,timestep) 
	## some Decomposition Operator
	n=3
	At=new(Class="BoundLinDecompOp",
	  t_start,
	  t_end,
	  function(t0){
	        matrix(nrow=n,ncol=n,byrow=TRUE,
	          c(-1,    0.1,    0, 
	             0.5  , -0.4,    0,   
	             0,    0.2,   -0.1)
	        )
	  }
	) 
	 
	c0=c(100, 100, 100)
	
	## Atmospheric C_14
	
	F0=ConstFc(c(0,10,10),"Delta14C")
	
	## constant inputrate
	inputFluxes=new(
	  "TimeMap",
	  t_start,
	  t_end,
	  function(t0){matrix(nrow=n,ncol=1,c(10,10,10))}
	) 
	# we have a dataframe representing the C_14 fraction 
	# note that the time unit is in years and the fraction is given in
	# the Absolute Fraction Modern format.
	# This means that all the other data provided are assumed to have the same value
	# This is especially true for the decay constants to be specified later
	Fc=BoundFc(C14Atm_NH,format="Delta14C")
	# add the C14 decay to the matrix which is done by a diagonal 
	# matrix which does not vary over time
	# we assume a half life th=5730 years
	th=5730
	k=log(0.5)/th #note that k is negative and has the unit y^-1
	
	mod=new("Model_14",t,At,c0,F0,inputFluxes,Fc,k)

#2.) provoke failure by demanding extrapolation to times where 
#    the model ingredienst are not specified (10 years later than the input e.g)
	t_toLong=seq(t_start,t_end+10,timestep) 
	checkException(new("Model_14",t_toLong,At,c0,F0,inputFluxes,Fc,k),
	"initialize must throw an exception because it is asked to build 
	an unvalid model"
	)
#3.) force an unsound model by settign pass to TRUE
	new("Model_14",t_toLong,At,c0,F0,inputFluxes,Fc,k,pass=TRUE)

SoilR documentation built on May 1, 2019, 8:06 p.m.