Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomei committed Nov 15, 2023
1 parent 4ccc7c6 commit 75c2a92
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 19 deletions.
12 changes: 7 additions & 5 deletions agrolib/mathFunctions/physics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ double vaporConcentrationFromPressure(double myPressure, double myT)


double airVolumetricSpecificHeat(double myPressure, double myT)
{ // (J m-3 K-1) volumetric specific heat of air

// (J m-3 K-1) volumetric specific heat of air
{
double myMolarDensity = airMolarDensity(myPressure, myT); // mol m-3
double mySpHeat = (HEAT_CAPACITY_AIR_MOLAR * myMolarDensity);
return (mySpHeat);
Expand Down Expand Up @@ -222,18 +222,20 @@ double aerodynamicConductance(double heightTemperature,
H = K * Ch * (soilSurfaceTemperature - airTemperature);
Sp = -VON_KARMAN_CONST * heightWind * GRAVITY * H / (Ch * airTemperature * (pow(uStar, 3)));
if (Sp > 0)
{// stability
{
// stability
psiH = 6 * log(1 + Sp);
psiM = psiH;
}
else
{// unstability
{
// unstability
psiH = -2 * log((1 + sqrt(1 - 16 * Sp)) / 2);
psiM = 0.6 * psiH;
}
}

return (K);
return K;

}

Expand Down
18 changes: 13 additions & 5 deletions agrolib/soilFluxes3D/boundary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,16 @@ double getSurfaceWaterFraction(int i)
}
}

void updateBoundary()
void updateConductance()
{
for (long i = 0; i < myStructure.nrNodes; i++)
if (myNode[i].boundary != nullptr)
if (myStructure.computeHeat)
if (myStructure.computeHeat)
{
for (long i = 0; i < myStructure.nrNodes; i++)
{
if (myNode[i].boundary != nullptr)
{
if (myNode[i].extra->Heat != nullptr)
{
if (myNode[i].boundary->type == BOUNDARY_HEAT_SURFACE)
{
// update aerodynamic conductance
Expand All @@ -218,12 +222,16 @@ void updateBoundary()
myNode[i].boundary->Heat->windSpeed);

if (myStructure.computeWater)
// update soil surface conductance
{
// update soil surface conductance
double theta = theta_from_sign_Psi(myNode[i].H - myNode[i].z, i);
myNode[i].boundary->Heat->soilConductance = 1./ computeSoilSurfaceResistance(theta);
}
}
}
}
}
}
}


Expand Down
2 changes: 1 addition & 1 deletion agrolib/soilFluxes3D/header/boundary.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

struct Tboundary;

void updateBoundary();
void updateConductance();
void updateBoundaryHeat();
void updateBoundaryWater(double deltaT);
void initializeBoundary(Tboundary *myBoundary, int myType, float slope, float boundaryArea);
Expand Down
10 changes: 8 additions & 2 deletions agrolib/soilFluxes3D/soilFluxes3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -815,8 +815,11 @@ int DLL_EXPORT __STDCALL setHydraulicProperties(int waterRetentionCurve,
InitializeBalanceWater();
if (myStructure.computeHeat)
initializeBalanceHeat();
else
balanceWholePeriod.heatMBR = 1.;
}


double DLL_EXPORT __STDCALL getWaterMBR()
{
return (balanceWholePeriod.waterMBR);
Expand Down Expand Up @@ -901,8 +904,11 @@ double DLL_EXPORT __STDCALL computeStep(double maxTime)
{
double dtWater, dtHeat;

if (myStructure.computeHeat) initializeHeatFluxes(false, true);
updateBoundary();
if (myStructure.computeHeat)
{
initializeHeatFluxes(false, true);
updateConductance();
}

if (myStructure.computeWater)
computeWater(maxTime, &dtWater);
Expand Down
10 changes: 5 additions & 5 deletions agrolib/soilFluxes3D/water.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,10 +347,10 @@ bool computeWater(double maxTime, double *acceptedTime)

/*! save the instantaneous H values - Prepare the solutions vector (X = H) */
for (long n = 0; n < myStructure.nrNodes; n++)
{
myNode[n].oldH = myNode[n].H;
X[n] = myNode[n].H;
}
{
myNode[n].oldH = myNode[n].H;
X[n] = myNode[n].H;
}

/*! assign Theta_e
for the surface nodes C = area */
Expand All @@ -363,7 +363,7 @@ bool computeWater(double maxTime, double *acceptedTime)
}

/*! update boundary conditions */
updateBoundary();
updateConductance();
updateBoundaryWater(*acceptedTime);

isStepOK = waterFlowComputation(*acceptedTime);
Expand Down
2 changes: 1 addition & 1 deletion bin/HEAT1D/linearGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ void LinearGraph::tooltipLineSeries(QPointF point, bool state)
double xValue = point.x();
double yValue = point.y();

m_tooltip->setText(QString("%1 \n%2 %3 ").arg(myCurveNames[index]).arg(xValue, 0, 'f', 1).arg(yValue, 0, 'f', 1));
m_tooltip->setText(QString("%1 \n%2 %3 ").arg(myCurveNames[index]).arg(xValue, 0, 'f', 1).arg(yValue, 0, 'f', 5));
m_tooltip->setSeries(serie);
m_tooltip->setAnchor(point);
m_tooltip->setZValue(11);
Expand Down

0 comments on commit 75c2a92

Please sign in to comment.