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

Apping API to get parameter values from IdealGas #66

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
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
25 changes: 25 additions & 0 deletions include/fprops/IdealGas.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,36 @@
/// @return Adiabatic index (ratio of specific heats cp/cv)
double get_gamma() const;

/// Get molar mass
///
/// @return Molar mass \f$[kg/mol]\f$
double get_molar_mass() const;

Check warning on line 28 in include/fprops/IdealGas.h

View workflow job for this annotation

GitHub Actions / c++ linter

include/fprops/IdealGas.h:28:5 [modernize-use-nodiscard]

function 'get_molar_mass' should be marked [[nodiscard]]

Check warning on line 28 in include/fprops/IdealGas.h

View workflow job for this annotation

GitHub Actions / c++ linter

include/fprops/IdealGas.h:28:12 [modernize-use-trailing-return-type]

use a trailing return type for this function

/// Get specific gas constant
///
/// @return Specific gas constant
double get_specific_gas_constant() const;

/// Get specific heat at constant pressure
///
/// @return Specific heat at constant pressure \f$[J/(kg-K)]\f$
double get_cp() const;

Check warning on line 38 in include/fprops/IdealGas.h

View workflow job for this annotation

GitHub Actions / c++ linter

include/fprops/IdealGas.h:38:5 [modernize-use-nodiscard]

function 'get_cp' should be marked [[nodiscard]]

Check warning on line 38 in include/fprops/IdealGas.h

View workflow job for this annotation

GitHub Actions / c++ linter

include/fprops/IdealGas.h:38:12 [modernize-use-trailing-return-type]

use a trailing return type for this function

/// Specific heat at constant volume \f$[J/(kg-K)]\f$
///
/// @return Specific heat at constant volume \f$[J/(kg-K)]\f$
double get_cv() const;

Check warning on line 43 in include/fprops/IdealGas.h

View workflow job for this annotation

GitHub Actions / c++ linter

include/fprops/IdealGas.h:43:5 [modernize-use-nodiscard]

function 'get_cv' should be marked [[nodiscard]]

Check warning on line 43 in include/fprops/IdealGas.h

View workflow job for this annotation

GitHub Actions / c++ linter

include/fprops/IdealGas.h:43:12 [modernize-use-trailing-return-type]

use a trailing return type for this function

/// Get dynamic viscosity
///
/// @return Dynamic viscosity \f$[Pa-s]\f$
double get_mu() const;

Check warning on line 48 in include/fprops/IdealGas.h

View workflow job for this annotation

GitHub Actions / c++ linter

include/fprops/IdealGas.h:48:5 [modernize-use-nodiscard]

function 'get_mu' should be marked [[nodiscard]]

Check warning on line 48 in include/fprops/IdealGas.h

View workflow job for this annotation

GitHub Actions / c++ linter

include/fprops/IdealGas.h:48:12 [modernize-use-trailing-return-type]

use a trailing return type for this function

/// Get thermal conductivity
///
/// @return Thermal conductivity \f$[W/(m-K)]\f$
double get_k() const;

Check warning on line 53 in include/fprops/IdealGas.h

View workflow job for this annotation

GitHub Actions / c++ linter

include/fprops/IdealGas.h:53:5 [modernize-use-nodiscard]

function 'get_k' should be marked [[nodiscard]]

Check warning on line 53 in include/fprops/IdealGas.h

View workflow job for this annotation

GitHub Actions / c++ linter

include/fprops/IdealGas.h:53:12 [modernize-use-trailing-return-type]

use a trailing return type for this function

/// Set dynamic viscosity
///
/// @param mu Dynamic viscosity \f$[Pa-s]\f$
Expand Down
30 changes: 30 additions & 0 deletions src/IdealGas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,42 @@ IdealGas::get_gamma() const
return this->gamma;
}

double
IdealGas::get_molar_mass() const
{
return this->molar_mass;
}

double
IdealGas::get_specific_gas_constant() const
{
return this->R_specific;
}

double
IdealGas::get_cp() const
{
return this->cp;
}

double
IdealGas::get_cv() const
{
return this->cv;
}

double
IdealGas::get_mu() const
{
return this->mu;
}

double
IdealGas::get_k() const
{
return this->k;
}

State
IdealGas::rho_T(double rho, double T) const
{
Expand Down
12 changes: 11 additions & 1 deletion test/src/IdealGas_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,19 @@ TEST(IdealGas, api)
{
double gamma = 1.4;
double molar_mass = 29.0e-3;
double mu = 18.23e-6;
double k = 25.68e-3;
IdealGas fp(gamma, molar_mass);
fp.set_mu(mu);
fp.set_k(k);

EXPECT_DOUBLE_EQ(fp.get_gamma(), gamma);
EXPECT_DOUBLE_EQ(fp.get_specific_gas_constant(), 286.70551034482759);
EXPECT_NEAR(fp.get_specific_gas_constant(), 286.7055103448, 1e-10);
EXPECT_DOUBLE_EQ(fp.get_molar_mass(), molar_mass);
EXPECT_NEAR(fp.get_cp(), 1003.4692862068, 1e-10);
EXPECT_NEAR(fp.get_cv(), 716.7637758620, 1e-10);
EXPECT_DOUBLE_EQ(fp.get_mu(), mu);
EXPECT_DOUBLE_EQ(fp.get_k(), k);
}

TEST(IdealGas, rho_T)
Expand Down
Loading