forked from forefireAPI/firefront
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LavaHCLFluxModel.cpp
executable file
·110 lines (87 loc) · 3.66 KB
/
LavaHCLFluxModel.cpp
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
/*
Copyright (C) 2012 ForeFire Team, SPE, Universit� de Corse.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 US
*/
#include "LavaHCLFluxModel.h"
using namespace std;
namespace libforefire {
/* name of the model */
const string LavaHCLFluxModel::name = "LavaHCLFlux";
/* instantiation */
FluxModel* getLavaHCLFluxModel(const int& index, DataBroker* db) {
return new LavaHCLFluxModel(index, db);
}
/* registration */
int LavaHCLFluxModel::isInitialized =
FireDomain::registerFluxModelInstantiator(name, getLavaHCLFluxModel );
/* constructor */
LavaHCLFluxModel::LavaHCLFluxModel(
const int & mindex, DataBroker* db)
: FluxModel(mindex, db) {
/* defining the properties needed for the model */
/* allocating the vector for the values of these properties */
if ( numProperties > 0 ) properties = new double[numProperties];
/* registering the model in the data broker */
dataBroker->registerFluxModel(this);
/* Definition of the coefficients */
arrivalTime = 5600.;
if(params->isValued("vaporFlux.activeArea"))
// cout<<params->getDouble("vaporFlux.activeArea")<<endl;
if ( params->isValued("laze.arrivalTime") )
arrivalTime = params->getDouble("laze.arrivalTime");
if ( !params->isValued("laze.hours") )
cout<<"ERROR: vector of parameters laze.hours should be valued"<<endl;
refHours = params->getDoubleArray("laze.hours");
if ( !params->isValued("laze.flows") )
cout<<"ERROR: vector of parameters laze.flows should be valued"<<endl;
refFlows = params->getDoubleArray("laze.flows");
exchangeArea = 80000.;
if ( params->isValued("laze.exchangeArea") )
exchangeArea = params->getDouble("laze.exchangeArea");
/* coefficients */
// Dividing by the final area of exchange to convert to kg.m-2.s-1
convert= 1./exchangeArea;
}
/* destructor (shoudn't be modified) */
LavaHCLFluxModel::~LavaHCLFluxModel() {
if ( properties != 0 ) delete properties;
}
/* accessor to the name of the model */
string LavaHCLFluxModel::getName(){
return name;
}
/* ****************** */
/* Model for the flux */
/* ****************** */
double LavaHCLFluxModel::getValue(double* valueOf
, const double& bt, const double& et, const double& at){
if ( bt - arrivalTime < 0 ) return 0.;
/* getting the hours since eruption */
double hoursSinceArrival = (bt-arrivalTime)/3600.;
if ( hoursSinceArrival > refHours.back() ) return 0.;
/* getting the index in the vector of fluxes */
size_t hind = 0;
size_t nhours = refHours.size();
while ( hind+1 < nhours and refHours[hind+1] < hoursSinceArrival ) hind++;
/* interpolation of the flux between the values */
double beta = (hoursSinceArrival-refHours[hind])
/(refHours[hind+1]-refHours[hind]);
double flux = beta*refFlows[hind+1] + (1.-beta)*refFlows[hind];
double HCL = flux * 0.00033 *0.5;
// cout << " fluxhcl" << flux << endl;
// cout << "LavaLaze " << params->getDouble("LavaHCLFlux.activeArea") +1 << endl ;
if((bt-at) < (35*3600)) return HCL /((params->getDouble("LavaHCLFlux.activeArea"))+1.);
return 0;
// return convert*flux/vaporFlux.activeArea;
}
} /* namespace libforefire */