Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code cleanup #811

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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