Conversation
… and updated author names and version numbers
…om prototypes in CNonPolytropicPengRobinson.hpp and CPengRobinson.hpp
|
This pull request introduces 3 alerts when merging e7adc45 into 27efebd - view on LGTM.com new alerts:
|
| % % | ||
| % SU2 configuration file % | ||
| % Case description: VKI turbine % | ||
| % Author: M. Pini, S. Vitale % |
There was a problem hiding this comment.
These headers can be updated/removed.
| % SU2 configuration file % | ||
| % Case description: Inviscid, internal flow over a bump in a channel % | ||
| % Author: Thomas D. Economon, B. Fuentes Monjas % | ||
| % Institution: Stanford University % |
| ../src/fluid/CIdealGas.cpp \ | ||
| ../src/fluid/CFluidScalar.cpp \ | ||
| ../src/fluid/CPengRobinson.cpp \ | ||
| ../src/fluid/CNonPolytropicPengRobinson.cpp \ |
There was a problem hiding this comment.
| ../src/fluid/CNonPolytropicPengRobinson.cpp \ | |
| ../src/fluid/CNonPolytropicPengRobinson.cpp \ |
| atanh = (log(1.0 + (b * sqrt2 / (v + b))) - log(1.0 - (b * sqrt2 / (v + b)))) / 2.0; | ||
|
|
||
| fv = atanh; |
There was a problem hiding this comment.
| atanh = (log(1.0 + (b * sqrt2 / (v + b))) - log(1.0 - (b * sqrt2 / (v + b)))) / 2.0; | |
| fv = atanh; | |
| su2double fv = (log(1.0 + (b * sqrt2 / (v + b))) - log(1.0 - (b * sqrt2 / (v + b)))) / 2.0;; |
| } | ||
|
|
||
| su2double CNonPolytropicPengRobinson::T_v_h(su2double v, su2double h){ | ||
| su2double toll = 1e-9, FACTOR = 0.2; |
There was a problem hiding this comment.
Would you be able to add more comments in these functions? A lot is happening here in the code but many variables/code sections don't provide insight to the function.
pcarruscag
left a comment
There was a problem hiding this comment.
Welcome to SU2! Please add yourself to AUTHORS.md
| if ((Kind_Solver == MAIN_SOLVER::EULER || Kind_Solver == MAIN_SOLVER::NAVIER_STOKES || Kind_Solver == MAIN_SOLVER::RANS) && (Kind_FluidModel == NPPR_GAS)) { | ||
| su2double sum = 0.0; | ||
| for (unsigned short iVar = 0; iVar < N_POLY_COEFFS; iVar++) { | ||
| sum += GetCp_PolyCoeff(iVar); | ||
| } | ||
| if ((N_POLY_COEFFS < 1) || (sum == 0.0)) | ||
| SU2_MPI::Error(string("CP_POLYCOEFFS not set for fluid model NPPR_GAS. \n"), CURRENT_FUNCTION); | ||
| } |
There was a problem hiding this comment.
Do this check together with the one above for INC_IDEAL_GAS_POLY, do not duplicate code please.
Do not check for N_POLY_COEFFS, it is a constant now.
| * \brief Child class for defining the non-polytropic Peng-Robinson model. | ||
| * \author: B. Fuentes Monjas | ||
| */ | ||
| class CNonPolytropicPengRobinson : public CPengRobinson { |
There was a problem hiding this comment.
| class CNonPolytropicPengRobinson : public CPengRobinson { | |
| class CNonPolytropicPengRobinson final : public CPengRobinson { |
| /*! | ||
| * \brief Internal function for the calculation of the integral of CP(IG)/T over T | ||
| */ | ||
| su2double ComputeIntegralCp0_T_DT(su2double T); |
There was a problem hiding this comment.
const everything you can please
| su2double ComputeIntegralCp0_T_DT(su2double T); | |
| su2double ComputeIntegralCp0_T_DT(su2double T) const; |
| @@ -110,7 +110,7 @@ class CPengRobinson final : public CIdealGas { | |||
| */ | |||
| void ComputeDerivativeNRBC_Prho(su2double P, su2double rho) override; | |||
There was a problem hiding this comment.
Where applicable switch the old overrides to final (now that this class is not final anymore).
| void ComputeDerivativeNRBC_Prho(su2double P, su2double rho) override; | |
| void ComputeDerivativeNRBC_Prho(su2double P, su2double rho) final; |
| CNonPolytropicPengRobinson::CNonPolytropicPengRobinson(su2double gamma, su2double R, su2double Pstar, su2double Tstar, su2double w, const CConfig *config) | ||
| : CPengRobinson (gamma, R, Pstar, Tstar, w) { | ||
| Temperature = TstarCrit; // Initialization of Temperature to critical value |
There was a problem hiding this comment.
run clang-format on the new files you are adding.
|
|
||
| d = (v * v + 2 * b * v - b * b); | ||
|
|
||
| atanh = (log(1.0 + (b * sqrt2 / (v + b))) - log(1.0 - (b * sqrt2 / (v + b)))) / 2.0; |
There was a problem hiding this comment.
don't use the name of a function as a variable, also, why didn't you use the atanh function directly? it's in the header
| su2double f, fv, C0, C1, C2, C4, C6, C8, C10, T, d, atanh; | ||
| su2double x1, x2, xmid, dx, fx1, fx2, fmid = 1.0, rtb; | ||
| su2double sqrt2 = sqrt(2.0); |
There was a problem hiding this comment.
introduce variables as you use them and make everything you can const
| fx1 = C0 + (C1 * x1) + (C2 * x1 * x1) + (C4 * x1 * x1 * x1 * x1) + (C6 * x1 * x1 * x1 * x1 * x1 * x1) + | ||
| (C8 * x1 * x1 * x1 * x1 * x1 * x1 * x1 * x1) + | ||
| (C10 * x1 * x1 * x1 * x1 * x1 * x1 * x1 * x1 * x1 * x1); | ||
| fx2 = C0 + (C1 * x2) + (C2 * x2 * x2) + (C4 * x2 * x2 * x2 * x2) + (C6 * x2 * x2 * x2 * x2 * x2 * x2) + | ||
| (C8 * x2 * x2 * x2 * x2 * x2 * x2 * x2 * x2) + | ||
| (C10 * x2 * x2 * x2 * x2 * x2 * x2 * x2 * x2 * x2 * x2); |
There was a problem hiding this comment.
Make a helper function to avoid repeating this, or at least a local lambda.
And please use pow(x, N) together with ffast-math the compiler does a better job than this linear unrolling.
| cout << "Root must be bracketed for bisection in rtbis\n" | ||
| "No solution in the temperature range specified" << endl; | ||
| } | ||
| rtb = f < 0.0 ? (static_cast<void>(dx = x2 - x1), x1) : (static_cast<void>(dx = x1 - x2), x2); |
There was a problem hiding this comment.
Write a normal if statement please, this is not very readable.
| int_cp0_T += coeffs_.at(i_cp) * log(T); | ||
| } else { | ||
| int_cp0_T += coeffs_.at(i_cp) * pow(T, i_cp) / (i_cp); |
There was a problem hiding this comment.
Do not use at on vectors or arrays, at checks bounds, here you are guaranteed to be within bounds.
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still a relevant issue please comment on it to restart the discussion. Thank you for your contributions. |
Proposed Changes
Added non-polytropic Peng-Robinson (NPPR_GAS) equation of state (CP temperature dependant model): the specific heat ratio is not constant but a polynomial model (CP = n0 + n1T + n2T^2 +n3T^3 + n4T^4) can be specified for the specific heat via the input file option (CP_POLYCOEFFS)
The NPPR fluid model uses the polytropic Peng-Robinson fluid model as a base class. Therefore, the polytropic Peng-Robinson class now allows for inheritance.
New test case (TestCases/nicfd/edge_NPPR) to compare the results of the NPPR with a constant CP model (CP = n0) and the polytropic Peng-Robinson models. The results of both simulations for this test case are equivalent.
Related Work
PR Checklist
Put an X by all that apply. You can fill this out after submitting the PR. If you have any questions, don't hesitate to ask! We want to help. These are a guide for you to know what the reviewers will be looking for in your contribution.