Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: wokast/RePrimAnd
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: public
Choose a base ref
...
head repository: jaykalinani/RePrimAnd
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: public
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 1 commit
  • 3 files changed
  • 1 contributor

Commits on Jul 5, 2023

  1. Copy the full SHA
    c0fef2a View commit details
Showing with 155 additions and 0 deletions.
  1. +8 −0 tests/src/meson.build
  2. +97 −0 tests/src/prim2con_mhd.cc
  3. +50 −0 tests/src/prim2con_mhd.h
8 changes: 8 additions & 0 deletions tests/src/meson.build
Original file line number Diff line number Diff line change
@@ -15,6 +15,14 @@ exe_tst_c2p = executable('test_c2p', sources : src_tst_c2p,
test('Con2Prim', exe_tst_c2p, timeout : 90)


src_tst_p2c = ['prim2con_mhd.cc', 'test_utils.cc']

exe_tst_p2c = executable('test_p2c', sources : src_tst_p2c,
dependencies : [dep_reprim, dep_utf],
cpp_args : '-DBOOST_TEST_DYN_LINK')

test('Prim2Con', exe_tst_p2c)

src_tst_eos = ['test_eos.cc', 'test_utils.cc']

exe_tst_eos = executable('test_eos', sources : src_tst_eos,
97 changes: 97 additions & 0 deletions tests/src/prim2con_mhd.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#define BOOST_TEST_MODULE con2prim
#include <boost/test/unit_test.hpp>
#include <limits>

#include "test_config.h"
#include "unitconv.h"
#include "test_con2prim_mhd.h"

#include "eos_thermal.h"
#include "eos_idealgas.h"
#include "eos_thermal_file.h"
#include "eos_hybrid.h"

using boost::format;
using boost::str;

using namespace std;
using namespace EOS_Toolkit;


void prim2con_mhd::setup_prim_cons(
prim_vars_mhd& pv, cons_vars_mhd& cv) const
{
pv = prim_vars_mhd(rho, eps, ye, press0,
vel0, wl0, E0, B0);
cv.from_prim(pv, g);
}

bool test_con2prim_mhd::check_isfinite(
const cons_vars_mhd& cv) const
{
failcount hope("All conserved vars finite");

hope.isfinite(cv.dens, "dens");
hope.isfinite(cv.tau, "tau");
hope.isfinite(cv.tracer_ye, "tracer_ye");
hope(check_isfinite(cv.scon), "scon finite");
hope(check_isfinite(cv.bcons), "bcons finite");

return hope;
}

bool test_con2prim_mhd::check_isfinite(
const prim_vars_mhd& pv) const
{
failcount hope("All primitive vars finite");

hope.isfinite(pv.rho, "rho");
hope.isfinite(pv.eps, "eps");
hope.isfinite(pv.ye, "ye");
hope.isfinite(pv.press, "press");
hope.isfinite(pv.w_lor, "w_lor");
hope(check_isfinite(pv.vel), "vel finite");
hope(check_isfinite(pv.E), "E finite");
hope(check_isfinite(pv.B), "B finite");

return hope;
}

bool test_con2prim_mhd::check_isfinite(
const cons_vars_mhd& cv,
const prim_vars_mhd& pv) const
{
return check_isfinite(pv) && check_isfinite(cv);
}


test_con2prim_mhd make_env(const env_idealgas& e)
{

auto eos = make_eos_idealgas(1.0, e.eps_max, e.rho_max);

const real_t atmo_ye{ 0.5 };
const real_t atmo_cut{ e.atmo_rho * 1.01 };
const real_t atmo_p{
eos.at_rho_eps_ye(e.atmo_rho, e.atmo_eps, atmo_ye).press()
};

atmosphere atmo{e.atmo_rho, e.atmo_eps, atmo_ye, atmo_p, atmo_cut};

const real_t rho_strict{ e.c2p_strict * e.atmo_rho };
const bool ye_lenient{ false };
const int max_iter{ 30 };
const real_t max_b{ 10. };
con2prim_mhd cv2pv(eos, rho_strict, ye_lenient, e.c2p_zmax, max_b,
atmo, e.c2p_acc, max_iter);

sm_metric3 g;
g.minkowski();

return test_con2prim_mhd(eos, g, atmo, cv2pv);
};

}



50 changes: 50 additions & 0 deletions tests/src/prim2con_mhd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include "test_utils.h"
#include "con2prim_imhd.h"
#include "eos_thermal.h"
#include <boost/format.hpp>

using EOS_Toolkit::eos_thermal;
using EOS_Toolkit::real_t;
using EOS_Toolkit::sm_metric3;
using EOS_Toolkit::sm_tensor1;
using EOS_Toolkit::atmosphere;
using EOS_Toolkit::con2prim_mhd;
using EOS_Toolkit::prim_vars_mhd;
using EOS_Toolkit::cons_vars_mhd;



struct env_idealgas {
real_t rho_max;
real_t eps_max;
real_t atmo_rho;
real_t atmo_eps;
real_t c2p_strict;
real_t c2p_zmax;
real_t c2p_acc;
};


struct env_hybrideos {
real_t atmo_rho;
real_t c2p_strict;
real_t c2p_zmax;
real_t c2p_acc;
};

class prim2con_mhd {
public:

eos_thermal eos;
sm_metric3 g;
atmosphere atmo;

void setup_prim_cons(prim_vars_mhd& pv,
cons_vars_mhd& cv) const;

bool check_isfinite(const cons_vars_mhd& cv) const;
bool check_isfinite(const prim_vars_mhd& pv) const;
bool check_isfinite(const cons_vars_mhd& cv,
const prim_vars_mhd& pv) const;
};