Skip to content

Commit

Permalink
fix calculateForwardSpreadRate and add tests reproducible in behave6
Browse files Browse the repository at this point in the history
  • Loading branch information
Kcheung42 committed Aug 29, 2024
1 parent 5ff32ad commit 2546ab6
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/behave/surfaceFire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,12 @@ double SurfaceFire::calculateForwardSpreadRate(int fuelModelNumber, bool hasDire

maxFlameLength_ = getFlameLength(); // Used by SAFETY Module

spreadRateInDirectionOfInterest_ = calculateSpreadRateAtVector(directionOfInterest, directionMode);
if (hasDirectionOfInterest) // propposed solution
{
spreadRateInDirectionOfInterest_ = calculateSpreadRateAtVector(directionOfInterest, directionMode);
}

std::cout << "spreadRateInDirectionOfInterest_:" << spreadRateInDirectionOfInterest_ << "\n";

if (!hasDirectionOfInterest) // If needed, calculate spread rate in arbitrary direction of interest
{
Expand Down
68 changes: 66 additions & 2 deletions src/testBehave/testBehave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ void testMortalityModule(TestInfo& testInfo, BehaveRun& behaveRun);
void testFineDeadFuelMoistureTool(TestInfo& testInfo, BehaveRun& behaveRun);
void testSlopeTool(TestInfo& testInfo, BehaveRun& behaveRun);
void testVaporPressureDeficitCalculator(TestInfo& testInfo, BehaveRun& behaveRun);
void testSimpleSurface(TestInfo& testInfo, BehaveRun& behaveRun);

int main()
{
Expand Down Expand Up @@ -84,6 +85,7 @@ int main()
testFineDeadFuelMoistureTool(testInfo, behaveRun);
testSlopeTool(testInfo, behaveRun);
testVaporPressureDeficitCalculator(testInfo, behaveRun);
testSimpleSurface(testInfo, behaveRun);

std::cout << "Total tests performed: " << testInfo.numTotalTests << "\n";
if(testInfo.numPassed > 0)
Expand Down Expand Up @@ -1323,6 +1325,8 @@ void testSpotModule(TestInfo& testInfo, BehaveRun& behaveRun)

setSurfaceInputsForGS4LowMoistureScenario(behaveRun);
behaveRun.surface.setWindHeightInputMode(WindHeightInputMode::TwentyFoot);
behaveRun.surface.setUserProvidedWindAdjustmentFactor(1.0);
behaveRun.surface.setWindAdjustmentFactorCalculationMethod(WindAdjustmentFactorCalculationMethod::UserInput);
behaveRun.surface.doSurfaceRunInDirectionOfMaxSpread();
flameLength = behaveRun.surface.getFlameLength(LengthUnits::Feet);

Expand Down Expand Up @@ -1387,12 +1391,12 @@ void testSpotModule(TestInfo& testInfo, BehaveRun& behaveRun)
behaveRun.spot.calculateSpottingDistanceFromSurfaceFire();

testName = "Test mountain spotting distance from surface fire, closed downwind canopy";
expectedMountainSpottingDistance = 0.107189;
expectedMountainSpottingDistance = 0.267467;
observedMountainSpottingDistance = roundToSixDecimalPlaces(behaveRun.spot.getMaxMountainousTerrainSpottingDistanceFromSurfaceFire(spottingDistanceUnits));
reportTestResult(testInfo, testName, observedMountainSpottingDistance, expectedMountainSpottingDistance, error_tolerance);

testName = "Test flat spotting distance from surface fire, closed downwind canopy";
expectedFlatSpottingDistance = 0.086155999999999996;
expectedFlatSpottingDistance = 0.22005;
observedFlatSpottingDistance = roundToSixDecimalPlaces(behaveRun.spot.getMaxFlatTerrainSpottingDistanceFromSurfaceFire(spottingDistanceUnits));
reportTestResult(testInfo, testName, observedFlatSpottingDistance, expectedFlatSpottingDistance, error_tolerance);

Expand Down Expand Up @@ -1427,6 +1431,7 @@ void testSpeedUnitConversion(TestInfo& testInfo, BehaveRun& behaveRun)
SpeedUnits::SpeedUnitsEnum windSpeedUnits = SpeedUnits::MilesPerHour;
WindHeightInputMode::WindHeightInputModeEnum windHeightInputMode = WindHeightInputMode::TwentyFoot;

behaveRun.surface.setWindAdjustmentFactorCalculationMethod(WindAdjustmentFactorCalculationMethod::UseCrownRatio);
setSurfaceInputsForGS4LowMoistureScenario(behaveRun);

// Test using upslope oriented mode, 20 foot uplsope wind
Expand Down Expand Up @@ -1922,3 +1927,62 @@ void testVaporPressureDeficitCalculator(TestInfo& testInfo, BehaveRun& behaveRun

std::cout << "Finished testing Slope Tool\n\n";
}


void testSimpleSurface(TestInfo& testInfo, BehaveRun& behaveRun)
{
std::cout << "Testing Simple Surface\n";

string testName = "";

double expectedRateofSpread = 0.0;
double observedRateofSpread = 0.0;

int fuelModelNumber = 124; // fuel model gs4(124) chosen as it is dynamic and has values for all moisture classes
double moistureOneHour = 6.0;
double moistureTenHour = 7.0;
double moistureHundredHour = 8.0;
double moistureLiveHerbaceous = 60.0;
double moistureLiveWoody = 90.0;
FractionUnits::FractionUnitsEnum moistureUnits = FractionUnits::Percent;
double windSpeed = 5.0;
WindHeightInputMode::WindHeightInputModeEnum windHeightInputMode = WindHeightInputMode::TwentyFoot;
SpeedUnits::SpeedUnitsEnum windSpeedUnits = SpeedUnits::MilesPerHour;
double windDirection = 0;
WindAndSpreadOrientationMode::WindAndSpreadOrientationModeEnum windAndSpreadOrientationMode = WindAndSpreadOrientationMode::RelativeToNorth;
double slope = 30.0;
SlopeUnits::SlopeUnitsEnum slopeUnits = SlopeUnits::Percent;
double aspect = 0;
double canopyCover = 0.0;
FractionUnits::FractionUnitsEnum canopyCoverUnits = FractionUnits::Percent;
double canopyHeight = 0.0;
LengthUnits::LengthUnitsEnum canopyHeightUnits = LengthUnits::Feet;
double crownRatio = 0.0;

behaveRun.surface.updateSurfaceInputs(fuelModelNumber, moistureOneHour, moistureTenHour, moistureHundredHour, moistureLiveHerbaceous,
moistureLiveWoody, moistureUnits, windSpeed, windSpeedUnits, windHeightInputMode, windDirection, windAndSpreadOrientationMode,
slope, slopeUnits, aspect, canopyCover, canopyCoverUnits, canopyHeight, canopyHeightUnits, crownRatio, FractionUnits::Fraction);

behaveRun.surface.setUserProvidedWindAdjustmentFactor(1.0);
behaveRun.surface.setWindAdjustmentFactorCalculationMethod(WindAdjustmentFactorCalculationMethod::UserInput);
behaveRun.surface.setWindHeightInputMode(WindHeightInputMode::TwentyFoot);
behaveRun.surface.setWindAndSpreadOrientationMode(WindAndSpreadOrientationMode::RelativeToNorth);
behaveRun.surface.doSurfaceRunInDirectionOfMaxSpread();

testName = "Test Simple Surface Rate of Spread";
expectedRateofSpread = 34.011429;
observedRateofSpread = roundToSixDecimalPlaces(behaveRun.surface.getSpreadRate(SpeedUnits::ChainsPerHour));
reportTestResult(testInfo, testName, observedRateofSpread, expectedRateofSpread, error_tolerance);


testName = "Test Simple Surface Flame Length";
expectedRateofSpread = 15.811421;
observedRateofSpread = roundToSixDecimalPlaces(behaveRun.surface.getFlameLength(LengthUnits::Feet));
reportTestResult(testInfo, testName, observedRateofSpread, expectedRateofSpread, error_tolerance);


testName = "Test Simple Surface FirelineIntensity";
expectedRateofSpread = 2292.684759;
observedRateofSpread = roundToSixDecimalPlaces(behaveRun.surface.getFirelineIntensity(FirelineIntensityUnits::BtusPerFootPerSecond));
reportTestResult(testInfo, testName, observedRateofSpread, expectedRateofSpread, error_tolerance);
}

0 comments on commit 2546ab6

Please sign in to comment.