forked from perabrahamsen/daisy-model
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbioclimate.C
92 lines (79 loc) · 2.66 KB
/
bioclimate.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
// bioclimate.C
//
// Copyright 1996-2001 Per Abrahamsen and Søren Hansen
// Copyright 2000-2001 KVL.
//
// 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 "bioclimate.h"
#include "weather.h"
#include "block_model.h"
#include "mathlib.h"
#include "librarian.h"
const char *const Bioclimate::component = "bioclimate";
symbol
Bioclimate::library_id () const
{
static const symbol id (component);
return id;
}
double
Bioclimate::day_fraction (const double dt) const
{
if (daily_global_radiation () > 0.0)
return (dt * global_radiation ())/ (24.0 * daily_global_radiation ());
return 0.0;
}
void
Bioclimate::radiation_distribution (const size_t No, const double LAI,
const double Ref,
const double Si,
const double Ext,
std::vector <double>& Rad)
{
// Fraction of Photosynthetically Active Radiation in Shortware
// incoming radiation.
static const double PARinSi = 0.50;
const double PAR0 = (1 - Ref) * PARinSi * Si;
intensity_distribution (No, LAI, PAR0, Ext, Rad);
}
void
Bioclimate::intensity_distribution (const size_t No, const double LAI,
const double Rad0,
const double Ext,
std::vector <double>& Rad)
{
daisy_assert (Rad.size () == No + 1);
const double dLAI = (LAI / (No + 0.0));
for (size_t i = 0; i <= No; i++)
Rad[i] = Rad0 * exp (- Ext * dLAI * i);
}
Bioclimate::Bioclimate (const BlockModel& al)
: ModelFramed (al)
{ }
Bioclimate::~Bioclimate ()
{ }
static struct BioclimateInit : public DeclareComponent
{
BioclimateInit ()
: DeclareComponent (Bioclimate::component, "\
The 'bioclimate' component is responsible for distributing the water\n\
and energy provided by the weather component among the crops and soil\n\
for a given column.")
{ }
} Bioclimate_init;
// bioclimate.C ends here.