Skip to content

Commit

Permalink
Merge pull request OpenWaterAnalytics#811 from LRossman/dev-leakage
Browse files Browse the repository at this point in the history
Code cleanup
  • Loading branch information
LRossman authored Jul 29, 2024
2 parents 3e1702e + cbf543f commit 2f4ae4c
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions src/leakage.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static void convert_pipe_to_node_leakage(Project *pr);
static void init_node_leakage(Project *pr);
static int leakage_headloss(Project* pr, int i, double *hfa,
double *gfa, double *hva, double *gva);
static void eval_leak_headloss(double RQtol, double q, double c,
static void eval_leak_headloss(double q, double c,
double n, double *hloss, double *hgrad);
static void add_lower_barrier(double q, double *hloss, double *hgrad);

Expand Down Expand Up @@ -470,25 +470,24 @@ int leakage_headloss(Project* pr, int i, double *hfa, double *gfa,
*gfa = 0.0;
}
else
eval_leak_headloss(hyd->RQtol, hyd->Leakage[i].qfa, hyd->Leakage[i].cfa,
eval_leak_headloss(hyd->Leakage[i].qfa, hyd->Leakage[i].cfa,
0.5, hfa, gfa);
if (hyd->Leakage[i].cva == 0.0)
{
*hva = 0.0;
*gva = 0.0;
}
else
eval_leak_headloss(hyd->RQtol, hyd->Leakage[i].qva, hyd->Leakage[i].cva,
eval_leak_headloss(hyd->Leakage[i].qva, hyd->Leakage[i].cva,
1.5, hva, gva);
return TRUE;
}

void eval_leak_headloss(double RQtol, double q, double c, double n,
void eval_leak_headloss(double q, double c, double n,
double *hloss, double *hgrad)
/*
**--------------------------------------------------------------
** Input: RQtol = low gradient tolerance (ft/cfs)
** q = leakage flow rate (cfs)
** Input: q = leakage flow rate (cfs)
** c = leakage head loss coefficient
** n = leakage head loss exponent
** Output: hloss = leakage head loss (ft)
Expand All @@ -504,17 +503,7 @@ void eval_leak_headloss(double RQtol, double q, double c, double n,
{
n = 1.0 / n;
*hgrad = n * c * pow(fabs(q), n - 1.0);

// Use linear head loss function for small gradient
/* if (*hgrad < RQtol)
{
*hgrad = RQtol / n;
*hloss = (*hgrad) * q;
}
// Otherwise use normal leakage head loss function
else */
*hloss = (*hgrad) * q / n;
*hloss = (*hgrad) * q / n;

// Prevent leakage from going negative
add_lower_barrier(q, hloss, hgrad);
Expand Down

0 comments on commit 2f4ae4c

Please sign in to comment.