Skip to content

Commit

Permalink
working on KdS background
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaunFell committed Apr 18, 2024
1 parent 592a255 commit e2ff65e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 129 deletions.
136 changes: 17 additions & 119 deletions tests/KdS_test/Main_Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,9 @@ for more details
// background includes
#include "ADMFixedBGVars.hpp"
#include "BaseProcaFieldTest.hpp"
#include "BoostedBH.hpp"
#include "KerrSchild.hpp"
#include "KerrSchildFixedBG.hpp"
#include "MatterEvolution.hpp"
#include "ProcaField.hpp"
#include "KerrdeSitter.hpp"

#include "BaseProcaField.hpp"
#include "ProcaField.hpp"
Expand All @@ -58,114 +56,19 @@ for more details

std::string tab{"\t"};

void test1()
{
std::cout << "\n\n KerrSchild test:" << std::endl;

double dx{1e-3};

// initialize an IntVect object
IntVect intvect;
intvect[0] = 0.5;
intvect[1] = 0.5;
intvect[2] = 0.5;

// create a coordinate object
// We set the coordinates to some arbitrary value, but which
// correspond to the
// values in the Mathematica notebook
Coordinates<double> coords(
intvect, dx,
{0, 0, 0}); // should correspond to the point (x,y,z) = (1,1,1)
const double x = coords.x;
const double y = coords.y;
const double z = coords.z;
std::cout << tab << "(x,y,z) = (" << x << "," << y << "," << z << ")"
<< std::endl;

// initialize the kerr params and the kerr object
KerrSchild::params_t kerr_params;
kerr_params.mass = 1.0;
kerr_params.spin = 0.5;
// kerr_params.center = {0.0, 0.0, 0.0};
KerrSchild kerr_init(kerr_params, dx);
std::cout << tab << " kerr mass = " << kerr_params.mass << std::endl;
std::cout << tab << " kerr spin = " << kerr_params.spin << std::endl;

// instantiate the metric variables
ADMFixedBGVars::Vars<double> metric_vars;

// the real work
// init reference class
KerrSchildFixedBG::params_t ref_params = {
kerr_params.mass, kerr_params.center, kerr_params.spin};
KerrSchildFixedBG kerr_ref(ref_params, dx);

// Excision test
{
// setup container objects for testing excision code
std::vector<double> ref_excision;
std::vector<double> my_excision;
IntVect excision_intvect(1., 1., 1.);

// First check BH params match
if (kerr_init.m_params.mass != kerr_ref.m_params.mass)
{
std::cout << "Mass test failed" << std::endl;
}
if (kerr_init.m_params.spin != kerr_ref.m_params.spin)
{
std::cout << "Spin test failed" << std::endl;
}

bool ExcisionPass{true};
double buffer{0.9554};
for (int i{0}; i < 3 / dx; i++)
{
excision_intvect[0] = 1.0;
excision_intvect[1] = 1.0;
excision_intvect[2] += i;

Box box(IntVect(0, 0, 0), IntVect(8, 8, 8));
FArrayBox fab_in(box, 3);
FArrayBox fab_out(box, 3);
auto box_pointers = BoxPointers{fab_in, fab_out};
Cell<double> current_cell(excision_intvect, box_pointers);
const Coordinates<double> coords(current_cell, dx,
kerr_params.center);
bool kerr_ref_excise_result{kerr_ref.excise(current_cell) < buffer};
bool kerr_init_excise_result{
kerr_init.check_if_excised(coords, buffer)};
if (kerr_ref_excise_result != kerr_init_excise_result)
{

std::cout << "Excision test failed" << std::endl;
std::cout << "Coordinate location: " << coords << std::endl;
std::cout << "kerr reference output: " << kerr_ref_excise_result
<< std::endl;
std::cout << "kerr my output: " << kerr_init_excise_result
<< std::endl;
ExcisionPass = false;
}
}
std::cout << "Excision passed: " << std::boolalpha << ExcisionPass
<< std::endl
<< std::endl
<< std::endl;
}
};

// This struct should be a copy of the background param_t struct, with specified
// values
struct
{
double mass = 1.0;
std::array<double, CH_SPACEDIM>
center; // automatically filled in during test2 eval
double velocity = 0.5;
std::array<double, CH_SPACEDIM> center; // automatically filled in during test2 eval
double cosmo_constant = 0.001;
double spin = 0.5;

} BackgroundParams;

template <class background_t> int test2()
int test2()
{

#ifdef _OPENMP
Expand Down Expand Up @@ -234,20 +137,22 @@ template <class background_t> int test2()
BackgroundParams.center = center_vector;

// create background
typename background_t::params_t bg_params;
typename KerrdeSitter::params_t bg_params;
bg_params.mass = BackgroundParams.mass;
bg_params.velocity = BackgroundParams.velocity;
bg_params.spin = BackgroundParams.spin;
bg_params.cosmo_constant = BackgroundParams.cosmo_constant;
bg_params.center = center_vector;
std::cout << "Mass: " << bg_params.mass << std::endl;
std::cout << "Velocity: " << bg_params.velocity << std::endl;
std::cout << "Spin: " << bg_params.spin << std::endl;
std::cout << "cosmo_constant: " << bg_params.cosmo_constant << std::endl;
std::cout << "Center: " << bg_params.center[0] << " "
<< bg_params.center[1] << " " << bg_params.center[2]
<< std::endl;
background_t background_init(bg_params, dx);
KerrdeSitter background_init(bg_params, dx);

std::cout << "Computing fixed background..." << std::endl;
// assign background variables to grid
BoxLoops::loop(AssignFixedBGtoBSSNVars<background_t>(background_init,
BoxLoops::loop(AssignFixedBGtoBSSNVars<KerrdeSitter>(background_init,
dx, center_vector),
fixedbg_FAB, fixedbg_FAB);
GammaCalculator gamamcalc(dx);
Expand Down Expand Up @@ -293,7 +198,7 @@ template <class background_t> int test2()
ProcaField analytic_matter(background_init, proca_params);

// compute RHS using analytic expressions
MatterEvolution<ProcaField, background_t> my_an_evolution(
MatterEvolution<ProcaField, KerrdeSitter> my_an_evolution(
analytic_matter, background_init, sigma, dx, center_vector);
BoxLoops::loop(my_an_evolution, fixedbg_FAB, fixedbg_rhs_FAB);

Expand All @@ -305,7 +210,7 @@ template <class background_t> int test2()
std::cout << "Excising..." << std::endl;

// excise the center where values are always large
ExcisionTest<BaseProcaField<background_t, ProcaField>, background_t>
ExcisionTest<BaseProcaField<KerrdeSitter, ProcaField>, KerrdeSitter>
excision(dx, center_vector, background_init);
BoxLoops::loop(excision, rhs_FAB, rhs_FAB, disable_simd());

Expand Down Expand Up @@ -414,17 +319,10 @@ int main(int argc, char *argv[])

std::cout << std::string(10, '#') << std::endl;
std::cout << std::string(10, '#') << std::endl;
std::cout << "current tests: KerrSchild" << std::endl;
std::cout << std::string(10, '#') << std::endl;
std::cout << std::string(10, '#') << std::endl;
test1();

std::cout << std::string(10, '#') << std::endl;
std::cout << std::string(10, '#') << std::endl;
std::cout << "current tests: KerrSchild Extended Test" << std::endl;
std::cout << "current tests: KerrdeSitter Extended Test" << std::endl;
std::cout << std::string(10, '#') << std::endl;
std::cout << std::string(10, '#') << std::endl;
int test2res = test2<BoostedBH>();
int test2res = test2();

return test2res;
}
10 changes: 5 additions & 5 deletions tests/KdS_test/ProcaField.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ This class adds the simplest L2 lagrangian to the base equations of motion
#include "ADMFixedBGVars.hpp"
#include "ADMProcaVars.hpp"
#include "BaseProcaField.hpp"
#include "BoostedBH.hpp"
#include "KerrdeSitter.hpp"
#include "DefaultG.hpp"
#include "KerrSchild.hpp"
#include "L2_simp.hpp"

// Note: base class BaseProcaField uses CRTP, so pass ProcaField itself as
// template argument
class ProcaField : public BaseProcaField<BoostedBH, ProcaField>
class ProcaField : public BaseProcaField<KerrdeSitter, ProcaField>
{

protected:
Expand All @@ -37,13 +37,13 @@ class ProcaField : public BaseProcaField<BoostedBH, ProcaField>
double vector_damping;
};

BoostedBH m_background;
KerrdeSitter m_background;
params_t m_params;
L2_t m_L2;
DefaultG m_G2;

ProcaField(BoostedBH a_background, params_t a_params)
: BaseProcaField<BoostedBH, ProcaField>(a_background),
ProcaField(KerrdeSitter a_background, params_t a_params)
: BaseProcaField<KerrdeSitter, ProcaField>(a_background),
m_background(a_background), m_params(a_params)
{
// set up the L2 lagrangian
Expand Down
10 changes: 5 additions & 5 deletions tests/KdS_test/ProcaFieldTest.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ This class adds the simplest L2 lagrangian to the base equations of motion
#include "ADMFixedBGVars.hpp"
#include "ADMProcaVars.hpp"
#include "BaseProcaField.hpp"
#include "BoostedBH.hpp"
#include "KerrdeSitter.hpp"
#include "DefaultG.hpp"
#include "L2_simp.hpp"

// Note: base class BaseProcaField uses CRTP, so pass ProcaField itself as
// template argument
class ProcaFieldTest : public BaseProcaFieldTest<BoostedBH, ProcaFieldTest>
class ProcaFieldTest : public BaseProcaFieldTest<KerrdeSitter, ProcaFieldTest>
{

protected:
Expand All @@ -36,13 +36,13 @@ class ProcaFieldTest : public BaseProcaFieldTest<BoostedBH, ProcaFieldTest>
double vector_damping;
};

BoostedBH m_background;
KerrdeSitter m_background;
params_t m_params;
L2_t m_L2;
DefaultG m_G2;

ProcaFieldTest(BoostedBH a_background, params_t a_params)
: BaseProcaFieldTest<BoostedBH, ProcaFieldTest>(a_background),
ProcaFieldTest(KerrdeSitter a_background, params_t a_params)
: BaseProcaFieldTest<KerrdeSitter, ProcaFieldTest>(a_background),
m_background(a_background), m_params(a_params)
{
// set up the L2 lagrangian
Expand Down

0 comments on commit e2ff65e

Please sign in to comment.