forked from perabrahamsen/daisy-model
-
Notifications
You must be signed in to change notification settings - Fork 0
/
adsorption.C
195 lines (163 loc) · 4.75 KB
/
adsorption.C
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
// adsorption.C -- Equilibrium between sorbed and solute states.
//
// Copyright 1996-2001 Per Abrahamsen and Søren Hansen
// Copyright 2000-2001 KVL.
// Copyright 2008 Per Abrahamsen and University of Copenhagen.
//
// This file is part of Daisy.
//
// Daisy is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// Daisy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser Public License for more details.
//
// You should have received a copy of the GNU Lesser Public License
// along with Daisy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#define BUILD_DLL
#include "adsorption.h"
#include "soil.h"
#include "block_model.h"
#include "librarian.h"
#include "mathlib.h"
// "adsorption" component.
const char *const Adsorption::component = "adsorption";
symbol
Adsorption::library_id () const
{
static const symbol id (component);
return id;
}
bool
Adsorption::full () const
{ return false; }
void
Adsorption::output (Log&) const
{ }
double
Adsorption::C_to_M_total (const Soil& soil, double Theta, int i, double C) const
{ return C_to_M (soil, Theta, i, C, 1.0); }
double
Adsorption::M_to_C_total (const Soil& soil, double Theta, int i, double M) const
{ return M_to_C (soil, Theta, i, M, 1.0); }
double
Adsorption::C_to_M1 (const Soil& soil, double Theta, int i, double C) const
{
const double sf = soil.primary_sorption_fraction (i);
return C_to_M (soil, Theta, i, C, sf);
}
double
Adsorption::M_to_C1 (const Soil& soil, double Theta, int i, double M) const
{
const double sf = soil.primary_sorption_fraction (i);
return M_to_C (soil, Theta, i, M, sf);
}
double
Adsorption::C_to_M2 (const Soil& soil, double Theta, int i, double C) const
{
const double sf = 1.0 - soil.primary_sorption_fraction (i);
return C_to_M (soil, Theta, i, C, sf);
}
double
Adsorption::M_to_C2 (const Soil& soil, double Theta, int i, double M) const
{
const double sf = 1.0 - soil.primary_sorption_fraction (i);
return M_to_C (soil, Theta, i, M, sf);
}
Adsorption::Adsorption (const char *const type)
: ModelDerived (symbol (type))
{ }
Adsorption::Adsorption (const BlockModel& al)
: ModelDerived (al.type_name ())
{ }
Adsorption::~Adsorption ()
{ }
static struct AdsorptionInit : public DeclareComponent
{
AdsorptionInit ()
: DeclareComponent (Adsorption::component, "\
This component describes the adsorption of a chemical to the soil,\n\
which among other things affects how large a fraction can be\n\
transported with the water.")
{ }
void load_frame (Frame& frame) const
{ Model::load_model (frame); }
} Adsorption_init;
// "linear" special.
AdsorptionLinear::AdsorptionLinear (const BlockModel& al)
: Adsorption (al)
{ }
// "none" model.
class AdsorptionNone : public Adsorption
{
// Simulation.
public:
double C_to_M (const Soil&, double Theta, int, double C, double) const
{ return C * Theta; }
double M_to_C (const Soil&, double Theta, int, double M, double) const
{ return M / Theta; }
// Create.
public:
AdsorptionNone ()
: Adsorption ("none")
{ }
AdsorptionNone (const BlockModel& al)
: Adsorption (al)
{ }
};
const Adsorption&
Adsorption::none ()
{
static const AdsorptionNone none;
return none;
}
static struct AdsorptionNoneSyntax : DeclareModel
{
Model* make (const BlockModel& al) const
{ return new AdsorptionNone (al); }
AdsorptionNoneSyntax ()
: DeclareModel (Adsorption::component, "none", "No adsorption.\n\
Used for solutes that are not adsorped to the soil.")
{ }
void load_frame (Frame& frame) const
{ }
} AdsorptionNone_syntax;
// "full" model.
class AdsorptionFull : public Adsorption
{
// Simulation.
public:
bool full () const
{ return true; }
double C_to_M (const Soil&, double Theta, int, double C, double) const
{
if (fabs (C) < 1.0e-100)
return 0.0;
// If we initialized a non-zero C, put it all in M right away.
return C * Theta;
}
double M_to_C (const Soil&, double, int, double, double) const
{ return 0; }
// Create.
public:
AdsorptionFull (const BlockModel& al)
: Adsorption (al)
{ }
};
static struct AdsorptionFullSyntax : DeclareModel
{
Model* make (const BlockModel& al) const
{ return new AdsorptionFull (al); }
AdsorptionFullSyntax ()
: DeclareModel (Adsorption::component, "full", "Full adsorption.\n\
Used for non-solutes, fully adsorped in the soil.")
{ }
void load_frame (Frame& frame) const
{ }
} AdsorptionFull_syntax;
// adsorption.C ends here.