Skip to content

Commit

Permalink
Removed Ham_abs variable (got it mixed up with Ham_abs_terms)
Browse files Browse the repository at this point in the history
  • Loading branch information
the-florist committed Jul 30, 2024
1 parent 40fbf97 commit dfcbca5
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 25 deletions.
10 changes: 5 additions & 5 deletions Examples/ScalarField/ConstraintStatistics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ class ConstraintStatistics
CH_TIME("ConstraintStatistics::compute");

data_t Ham = current_cell.load_vars(c_Ham);
data_t HamAbs = current_cell.load_vars(c_Ham_abs);
data_t HamAbs = current_cell.load_vars(c_Ham_abs_terms);
data_t HamAbsAAD = abs(HamAbs - m_Ham_abs_mean);
data_t HamVar = pow(Ham - m_Ham_mean, 2.);
data_t HamNorm = Ham/m_Ham_abs_mean;
data_t HamNormSq = HamNorm*HamNorm;
data_t HamNorm = Ham/m_Ham_abs_mean;
data_t HamNormSq = HamNorm*HamNorm;

data_t Mom = current_cell.load_vars(c_Mom);
data_t MomAAD = abs(Mom - m_Mom_mean);

//store class (Vars) variables as diagnostic variables on the grid
current_cell.store_vars(HamNorm, c_Ham_norm);
current_cell.store_vars(HamNormSq, c_Ham_norm_sq);
current_cell.store_vars(HamVar, c_Ham_var);
current_cell.store_vars(HamNormSq, c_Ham_norm_sq);
current_cell.store_vars(HamVar, c_Ham_var);
current_cell.store_vars(HamAbsAAD, c_Ham_abs_AAD);
current_cell.store_vars(MomAAD, c_Mom_AAD);
}
Expand Down
2 changes: 0 additions & 2 deletions Examples/ScalarField/DiagnosticVariables.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ enum
c_ch2,

c_Ham,
c_Ham_abs,
c_Mom,
c_Ham_abs_terms,
c_Mom_abs_terms,
Expand All @@ -34,7 +33,6 @@ static const std::array<std::string, NUM_DIAGNOSTIC_VARS> variable_names = {
"ChiSq",

"Ham",
"HamAbs",
"Mom",
"Ham_abs_terms",
"Mom_abs_terms",
Expand Down
6 changes: 3 additions & 3 deletions Examples/ScalarField/ScalarFieldLevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void ScalarFieldLevel::prePlotLevel()
ScalarFieldWithPotential scalar_field(potential);
BoxLoops::loop(
MatterConstraints<ScalarFieldWithPotential>(
scalar_field, m_dx, m_p.G_Newton, c_Ham, c_Ham_abs, Interval(c_Mom, c_Mom), m_p.min_chi,
scalar_field, m_dx, m_p.G_Newton, c_Ham, Interval(c_Mom, c_Mom), m_p.min_chi,
c_Ham_abs_terms, Interval(c_Mom_abs_terms, c_Mom_abs_terms)),
m_state_new, m_state_diagnostics, EXCLUDE_GHOST_CELLS);
}
Expand Down Expand Up @@ -183,7 +183,7 @@ void ScalarFieldLevel::specificPostTimeStep()
ScalarFieldWithPotential scalar_field(potential);
BoxLoops::loop(
MatterConstraints<ScalarFieldWithPotential>(
scalar_field, m_dx, m_p.G_Newton, c_Ham, c_Ham_abs, Interval(c_Mom, c_Mom), m_p.min_chi,
scalar_field, m_dx, m_p.G_Newton, c_Ham, Interval(c_Mom, c_Mom), m_p.min_chi,
c_Ham_abs_terms, Interval(c_Mom_abs_terms, c_Mom_abs_terms)),
m_state_new, m_state_diagnostics, EXCLUDE_GHOST_CELLS);

Expand All @@ -194,7 +194,7 @@ void ScalarFieldLevel::specificPostTimeStep()
double vol = amr_reductions.get_domain_volume();

double hamBar = amr_reductions.sum(c_Ham)/vol;
double hamAbsBar = amr_reductions.sum(c_Ham_abs)/vol;
double hamAbsBar = amr_reductions.sum(c_Ham_abs_terms)/vol;
double momBar = amr_reductions.sum(c_Mom)/vol;

BoxLoops::loop(
Expand Down
4 changes: 1 addition & 3 deletions Source/CCZ4/NewConstraints.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class Constraints
template <class data_t> struct Vars
{
data_t Ham;
data_t Ham_abs;
data_t Ham_abs_terms;
Tensor<1, data_t> Mom;
Tensor<1, data_t> Mom_abs_terms;
Expand All @@ -47,7 +46,7 @@ class Constraints
// conformally decomposed expressions which can be used in to normalize
// the constraint violations
// Any zero-length Interval or negative var is not calculated
Constraints(double dx, int a_c_Ham, int a_c_Ham_abs, const Interval &a_c_Moms,
Constraints(double dx, int a_c_Ham, const Interval &a_c_Moms,
const double a_c_chi_min,
int a_c_Ham_abs_terms = -1,
const Interval &a_c_Moms_abs_terms = Interval(),
Expand All @@ -58,7 +57,6 @@ class Constraints
protected:
const FourthOrderDerivatives m_deriv;
const int m_c_Ham;
const int m_c_Ham_abs;
const Interval m_c_Moms;
const double m_min_chi;
const int m_c_Ham_abs_terms = -1;
Expand Down
10 changes: 3 additions & 7 deletions Source/CCZ4/NewConstraints.impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
#include "VarsTools.hpp"

inline Constraints::Constraints(
double dx, int a_c_Ham, int a_c_Ham_abs, const Interval &a_c_Moms,
double dx, int a_c_Ham, const Interval &a_c_Moms,
const double a_c_chi_min,
int a_c_Ham_abs_terms /*defaulted*/,
const Interval &a_c_Moms_abs_terms /*defaulted*/,
double cosmological_constant /*defaulted*/)
: m_deriv(dx), m_c_Ham(a_c_Ham), m_c_Ham_abs(a_c_Ham_abs), m_c_Moms(a_c_Moms),
: m_deriv(dx), m_c_Ham(a_c_Ham), m_c_Moms(a_c_Moms),
m_min_chi(a_c_chi_min),
m_c_Ham_abs_terms(a_c_Ham_abs_terms),
m_c_Moms_abs_terms(a_c_Moms_abs_terms),
Expand Down Expand Up @@ -52,7 +52,7 @@ Constraints::Vars<data_t> Constraints::constraint_equations(
{
Vars<data_t> out;

if (m_c_Ham >= 0 || m_c_Ham_abs_terms >= 0 || m_c_Ham_abs >= 0)
if (m_c_Ham >= 0 || m_c_Ham_abs_terms >= 0)
{
auto ricci = CCZ4Geometry::compute_ricci(vars, d1, d2, h_UU, chris);

Expand All @@ -67,8 +67,6 @@ Constraints::Vars<data_t> Constraints::constraint_equations(
abs(ricci.scalar) + abs(tr_A2) +
abs((GR_SPACEDIM - 1.) * vars.K * vars.K / GR_SPACEDIM);
out.Ham_abs_terms += 2.0 * abs(m_cosmological_constant);

out.Ham_abs = abs(out.Ham);
}

if (m_c_Moms.size() > 0 || m_c_Moms_abs_terms.size() > 0)
Expand Down Expand Up @@ -112,8 +110,6 @@ void Constraints::store_vars(Vars<data_t> &out,
{
if (m_c_Ham >= 0)
current_cell.store_vars(out.Ham, m_c_Ham);
if (m_c_Ham_abs >= 0)
current_cell.store_vars(out.Ham_abs, m_c_Ham_abs);
if (m_c_Ham_abs_terms >= 0)
current_cell.store_vars(out.Ham_abs_terms, m_c_Ham_abs_terms);
if (m_c_Moms.size() == GR_SPACEDIM)
Expand Down
2 changes: 1 addition & 1 deletion Source/Matter/NewMatterConstraints.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ template <class matter_t> class MatterConstraints : public Constraints
hardcoded ones.
*/
MatterConstraints(const matter_t a_matter, double dx, double G_Newton,
int a_c_Ham, int a_c_Ham_abs, const Interval &a_c_Moms,
int a_c_Ham, const Interval &a_c_Moms,
const double a_c_chi_min,
int a_c_Ham_abs_terms = -1,
const Interval &a_c_Moms_abs_terms = Interval());
Expand Down
16 changes: 12 additions & 4 deletions Source/Matter/NewMatterConstraints.impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@

template <class matter_t>
MatterConstraints<matter_t>::MatterConstraints(
const matter_t a_matter, double dx, double G_Newton, int a_c_Ham, int a_c_Ham_abs,
const matter_t a_matter, double dx, double G_Newton, int a_c_Ham,
const Interval &a_c_Moms, const double a_c_chi_min, int a_c_Ham_abs_terms /* defaulted*/,
const Interval &a_c_Moms_abs_terms /*defaulted*/)
: Constraints(dx, a_c_Ham, a_c_Ham_abs, a_c_Moms, a_c_chi_min, a_c_Ham_abs_terms, a_c_Moms_abs_terms,
: Constraints(dx, a_c_Ham, a_c_Moms, a_c_chi_min, a_c_Ham_abs_terms, a_c_Moms_abs_terms,
0.0 /*No cosmological constant*/),
my_matter(a_matter), m_G_Newton(G_Newton)
{
Expand All @@ -41,13 +41,21 @@ void MatterConstraints<matter_t>::compute(Cell<data_t> current_cell) const
// Energy Momentum Tensor
const auto emtensor = my_matter.compute_emtensor(vars, d1, h_UU, chris.ULL);

/*cout << std::fixed << setprecision(12) << "Ham: " << out.Ham << "\n";
cout << std::fixed << setprecision(12) << "HamAbs: " << out.Ham_abs_terms << "\n";
cout << std::fixed << setprecision(12) << "Rho term: " << 16.0 * M_PI * m_G_Newton * emtensor.rho << "\n";*/
//MayDay::Error();

// Hamiltonian constraint
if (m_c_Ham >= 0 || m_c_Ham_abs_terms >= 0)
{
out.Ham += -16.0 * M_PI * m_G_Newton * emtensor.rho;
out.Ham_abs_terms += 16.0 * M_PI * m_G_Newton * abs(emtensor.rho);
out.Ham_abs = abs(out.Ham);
}
}

/*cout << std::fixed << setprecision(12) << "Ham with rho: " << out.Ham << "\n";
cout << std::fixed << setprecision(12) << "HamAbs with rho: " << out.Ham_abs_terms << "\n";
MayDay::Error();*/

// Momentum constraints
if (m_c_Moms.size() > 0 || m_c_Moms_abs_terms.size() > 0)
Expand Down

0 comments on commit dfcbca5

Please sign in to comment.