-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathPool.cs
More file actions
146 lines (129 loc) · 3.89 KB
/
Copy pathPool.cs
File metadata and controls
146 lines (129 loc) · 3.89 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
// Authors: Robert M. Scheller, James B. Domingo
using System;
namespace Landis.Library.UniversalCohorts
{
/// <summary>
/// The pool of dead biomass at a site.
/// </summary>
public class Pool
{
private double mass;
private double decayValue;
private double initialMass;
//---------------------------------------------------------------------
/// <summary>
/// Dead pool with initial values set to 0
/// </summary>
public Pool()
{
this.mass = 0;
this.decayValue = 0.0;
this.initialMass = 0.0;
}
//---------------------------------------------------------------------
/// <summary>
/// The litter pool's biomass.
/// </summary>
public double Mass
{
get
{
return mass;
}
set
{
mass = value;
}
}
//---------------------------------------------------------------------
/// <summary>
/// Litter pool decay rate.
/// </summary>
public double DecayValue
{
get
{
return decayValue;
}
set
{
decayValue = value;
}
}
/// <summary>
/// Initial mass of litter pool.
/// </summary>
public double InitialMass
{
get
{
return initialMass;
}
set
{
initialMass = value;
}
}
/// <summary>
/// Clone a copy of the pool
/// </summary>
/// <returns></returns>
public Pool Clone()
{
Pool newPool = new Pool();
newPool.Mass = this.mass;
newPool.DecayValue = this.decayValue;
newPool.InitialMass = this.initialMass;
return newPool;
}
//---------------------------------------------------------------------
/// <summary>
/// Adds some dead biomass (and associated C/N/P contents) to the pool.
/// </summary>
/// <remarks>
/// The pool's decomposition rate is adjusted by computing a weighted
/// average of the its current decay rate and the decay rate
/// associated with the incoming biomass.
/// </remarks>
public void AddMass(
double inputMass,
double inputDecayValue)
{
double totalBiomass = (Mass + inputMass);
if (totalBiomass == 0)
{
DecayValue = 0;
}
else
{
DecayValue = ((Mass * DecayValue) + (inputMass * inputDecayValue)) /
totalBiomass;
}
Mass = totalBiomass;
}
//---------------------------------------------------------------------
/// <summary>
/// Reduces the pool's biomass by a specified percentage.
/// </summary>
public double ReduceMass(double percentage)
{
if (percentage < 0.0 || percentage > 1.0)
throw new ArgumentException("Percentage must be between 0% and 100%");
double reduction = (mass * percentage);
mass -= (mass * percentage);
return reduction;
}
/// <summary>
/// Decomposes the pool's biomass for a year.
/// </summary>
public double Decompose()
{
//if (PlugIn.CalibrateMode && mass > 0)
// PlugIn.ModelCore.UI.WriteLine("Pool mass = {0}.", mass);
double oldmass = mass;
double newmass = (uint)(mass * Math.Exp(-decayValue));
mass = newmass;
return oldmass - newmass;
}
}
}