Fixes bugs in pump and demand head loss gradients
This commit is contained in:
@@ -505,22 +505,21 @@ void demandheadloss(Project *pr, int i, double dp, double n,
|
|||||||
*hloss = (*hgrad) * d;
|
*hloss = (*hgrad) * d;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise use power head loss function
|
// Use power head loss function for demand less than full
|
||||||
else
|
else if (r < 1.0)
|
||||||
{
|
{
|
||||||
*hgrad = n * dp * pow(r, n - 1.0) / dfull;
|
*hgrad = n * dp * pow(r, n - 1.0) / dfull;
|
||||||
*hloss = (*hgrad) * d / n;
|
*hloss = (*hgrad) * d / n;
|
||||||
|
}
|
||||||
|
|
||||||
// Add on barrier function for any demand above full value
|
// Use upper barrier function for demand above full value
|
||||||
if (r >= 1.0)
|
else
|
||||||
{
|
{
|
||||||
*hgrad += CBIG;
|
*hgrad = CBIG;
|
||||||
*hloss += CBIG * (d - dfull);
|
*hloss = dp + CBIG * (d - dfull);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void pipecoeff(Project *pr, int k)
|
void pipecoeff(Project *pr, int k)
|
||||||
/*
|
/*
|
||||||
@@ -761,7 +760,8 @@ void pumpcoeff(Project *pr, int k)
|
|||||||
if (n != 1.0)
|
if (n != 1.0)
|
||||||
{
|
{
|
||||||
// ... use linear approx. to pump curve for small flows
|
// ... use linear approx. to pump curve for small flows
|
||||||
qa = pow(hyd->RQtol / n / r, 1.0 / (n - 1.0));
|
if (pump->Ptype == CONST_HP) qa = -CBIG;
|
||||||
|
else qa = pow(hyd->RQtol / n / r, 1.0 / (n - 1.0));
|
||||||
if (q <= qa)
|
if (q <= qa)
|
||||||
{
|
{
|
||||||
hgrad = hyd->RQtol;
|
hgrad = hyd->RQtol;
|
||||||
|
|||||||
@@ -14,11 +14,12 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
//*** For the Windows SDK _tempnam function ***//
|
//*** For the Windows SDK _tempnam function ***//
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#else
|
||||||
|
#include <unistd.h >
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|||||||
Reference in New Issue
Block a user