Skip to content

Commit

Permalink
Merge branch 'main' into 87-flame-length-for-crown-fires-in-spain-model
Browse files Browse the repository at this point in the history
  • Loading branch information
matildeRivas authored Jan 15, 2025
2 parents 36ce40f + e5c615c commit 310aa18
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 9 deletions.
11 changes: 7 additions & 4 deletions Cell2Fire/Cell2Fire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ Cell2Fire::Cell2Fire(arguments _args)
this->crownFlameLengths = std::vector<float>(this->nCells, 0);
this->maxFlameLengths = std::vector<float>(this->nCells, 0);


this->ignProb = std::vector<float>(this->nCells, 1);
CSVParser.parsePROB(this->ignProb, DF, this->nCells);

Expand Down Expand Up @@ -626,7 +627,8 @@ Cell2Fire::InitCell(int id)
*/
void
Cell2Fire::reset(int rnumber, double rnumber2, int simExt = 1)
{ // Reset info
{
// Reset info
// DEBUGstd::cout << "--------------------- Reseting environment
// -----------------------" << std::endl;

Expand Down Expand Up @@ -746,7 +748,8 @@ Cell2Fire::reset(int rnumber, double rnumber2, int simExt = 1)
*/

if (this->args.WeatherOpt.compare("random") == 0)
{ // Random Weather
{
// Random Weather
this->CSVWeather.fileName
= this->args.InFolder + "Weathers" + separator() + "Weather" + std::to_string(rnumber) + ".csv";

Expand Down Expand Up @@ -889,8 +892,7 @@ Cell2Fire::reset(int rnumber, double rnumber2, int simExt = 1)
{
std::cout << "Maximum fire periods are set to: " << this->args.MaxFirePeriods
<< " based on the weather file, Fire Period Length, "
"and "
"Minutes per WP"
"and Minutes per WP"
<< std::endl;
}
}
Expand Down Expand Up @@ -938,6 +940,7 @@ Cell2Fire::reset(int rnumber, double rnumber2, int simExt = 1)
}
}


// Relevant sets: Initialization
this->availCells.clear();
this->nonBurnableCells.clear();
Expand Down
3 changes: 2 additions & 1 deletion Cell2Fire/Cells.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ typedef struct
{
char fueltype[4];
float ws, saz, cur, ps, cbh, ccf, cbd, elev, tmp, rh, lat, lon, ffmc, bui, gfl,
tree_height; // David: some variables only used on C2FK and not on C2FSB and// viceversa
tree_height; // David: some variables only used on C2FK and not on C2FSB and
// viceversa
int waz, nftype, FMC, time, pattern, mon, jd, jd_min, pc, pdf;
} inputs; // David: Moved here to simplify inclusion

Expand Down
1 change: 1 addition & 0 deletions Cell2Fire/DataGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,7 @@ GenDataFile(const std::string& InFolder, const std::string& Simulator)
// Call GenerateDat function
std::vector<std::vector<std::unique_ptr<std::string>>> result
= GenerateDat(GFuelType, GFuelTypeN, Elevation, PS, SAZ, Curing, CBD, CBH, CCF, PY, FMC, TreeHeight, InFolder);

writeDataToFile(result, InFolder);
std::cout << "File Generated";
}
1 change: 1 addition & 0 deletions Cell2Fire/DataGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ std::vector<std::vector<std::unique_ptr<std::string>>> GenerateDat(const std::ve
const std::vector<float>& PY,
const std::vector<float>& FMC,
const std::vector<float>& TreeHeight,

const std::string& InFolder);

void writeDataToFile(const std::vector<std::vector<std::unique_ptr<std::string>>>& dataGrids,
Expand Down
13 changes: 10 additions & 3 deletions Cell2Fire/FuelModelSpain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2364,6 +2364,7 @@ rate_of_spread10(inputs* data, arguments* args)

ws = data->ws;
ros10 = 1. / (p1 * exp(-p2 * ws * 0.4) + p3);

ros = ffros * ros10 + fccf * data->ccf + fcbd * args->CBDFactor;

return (ros);
Expand Down Expand Up @@ -2408,6 +2409,7 @@ crownfractionburn(inputs* data, main_outs* at)
{
a = -log(0.1) / (0.9 * (3.0 / cbd - ros0));
// a=0.23;

}
else
{
Expand Down Expand Up @@ -2503,8 +2505,9 @@ calculate_s(inputs* data,
// Step 9: Byram Intensity
at->sfi = byram_intensity(at, ptr);

// Step 10: Criterion for Crown Fire Initiation (no init if user does not// want
// to include it)

// Step 10: Criterion for Crown Fire Initiation (no init if user does not
// want to include it)
if (args->AllowCROS && data->cbh != 0 && data->cbd != 0)
{
if (activeCrown)
Expand Down Expand Up @@ -2549,6 +2552,7 @@ calculate_s(inputs* data,
at->crown_intensity = crown_byram_intensity(at, data);
at->crown_flame_length = crown_flame_length(at->crown_intensity);


at->a = (hptr->ros + bptr->ros) / 2.;
at->b = (hptr->ros + bptr->ros) / (2. * sec->lb);
at->c = (hptr->ros - bptr->rss) / 2;
Expand All @@ -2557,14 +2561,16 @@ calculate_s(inputs* data,
}
else if (activeCrown)
{
at->cfb = crownfractionburn(data, at); // lo calculamos igual porque lo necesitamos para el output
at->cfb = crownfractionburn(data,
at); // lo calculamos igual porque lo necesitamos para el output
hptr->ros = at->ros_active;
at->rss = hptr->ros;
bptr->ros = backfire_ros10_s(hptr, sec);
fptr->ros = flankfire_ros_s(hptr->ros, bptr->ros, sec->lb);
at->crown_intensity = crown_byram_intensity(at, data);
at->crown_flame_length = crown_flame_length(at->crown_intensity);


if (args->verbose)
{
cout << "hptr->ros = " << hptr->ros << "\n";
Expand Down Expand Up @@ -2659,6 +2665,7 @@ determine_destiny_metrics_s(inputs* data, fuel_coefs* ptr, arguments* args, main
metrics->cfb = crownfractionburn(data, metrics);
metrics->crown_intensity = crown_byram_intensity(metrics, data);
metrics->crown_flame_length = crown_flame_length(metrics->crown_intensity);

}
if (args->verbose)
{
Expand Down
6 changes: 5 additions & 1 deletion Cell2Fire/ReadCSV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,9 @@ CSVReader::printData(std::vector<std::vector<std::string>>& DF)
}

/*
* Populates the df input objects based on the DF csv file for each row/cell (spanish version)
* Populates the df input objects based on the DF csv file for each row/cell
* (spanish version)
*/
void
CSVReader::parseDF(inputs* df_ptr, std::vector<std::vector<std::string>>& DF, arguments* args_ptr, int NCells)
Expand All @@ -222,6 +224,7 @@ CSVReader::parseDF(inputs* df_ptr, std::vector<std::vector<std::string>>& DF, ar
// Floats
float cur, elev, ws, waz, saz, cbd, cbh, ccf, ps, lat, lon, ffmc, bui, gfl, tree_height;


// Integers
int nftype, FMC, jd, jd_min, pc, pdf, time, pattern;

Expand Down Expand Up @@ -355,6 +358,7 @@ CSVReader::parseDF(inputs* df_ptr, std::vector<std::vector<std::string>>& DF, ar
else
tree_height = std::stof(DF[i][24], &sz);


// Set values
strncpy(df_ptr->fueltype, faux, 4);
df_ptr->elev = elev;
Expand Down

0 comments on commit 310aa18

Please sign in to comment.