Skip to content

Commit

Permalink
cleaned up dat file printing and trying to recover same RF spectrum
Browse files Browse the repository at this point in the history
  • Loading branch information
the-florist committed Apr 25, 2024
1 parent 1414be7 commit 5e0a986
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
20 changes: 12 additions & 8 deletions Examples/ScalarField/ScalarFieldLevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ void ScalarFieldLevel::specificPostTimeStep()
double mass = m_p.potential_params.scalar_mass;

AMRReductions<VariableType::diagnostic> amr_reductions(m_gr_amr);
AMRReductions<VariableType::evolution> amr_evo_reductions(m_gr_amr);
double vol = amr_reductions.get_domain_volume();

BoxLoops::loop(MeansVars(m_dx, m_p.grid_params, m_p.data_path), m_state_new, m_state_diagnostics, FILL_GHOST_CELLS);
Expand All @@ -198,7 +199,7 @@ void ScalarFieldLevel::specificPostTimeStep()
double a = 1./sqrt(amr_reductions.sum(c_a)/vol);
double H = -amr_reductions.sum(c_H)/vol/3.;

double hambar = amr_reductions.sum(c_Ham)/vol;
//double hambar = amr_reductions.sum(c_Ham)/vol;
double hamabspbpSum = amr_reductions.sum(c_Ham_abs_pbp)/vol;
double mombar = amr_reductions.sum(c_Mom)/vol;
double habsbar = amr_reductions.sum(c_Ham_abs_terms)/vol;
Expand All @@ -213,21 +214,24 @@ void ScalarFieldLevel::specificPostTimeStep()

//Calculates variances
double phivar = amr_reductions.sum(c_sf2)/vol - phibar*phibar;
double chivar = amr_reductions.sum(c_ch2)/vol - c_a*c_a;
double chivar = amr_reductions.sum(c_ch2)/vol - pow(amr_reductions.sum(c_a)/vol, 2.);

//Calculates gauge quantities
double lapse = amr_reductions.sum(c_lapse)/vol;
double shift[3] = {amr_reductions.sum(c_shift1)/vol, amr_reductions.sum(c_shift2)/vol, amr_reductions.sum(c_shift3)/vol};
double lapse = amr_evo_reductions.sum(c_lapse)/vol;
double shift[3] = {amr_evo_reductions.sum(c_shift1)/vol,
amr_evo_reductions.sum(c_shift2)/vol,
amr_evo_reductions.sum(c_shift3)/vol};

//Prints all that out into the data/ directory
SmallDataIO means_file(m_p.data_path+"means_file", m_dt, m_time, m_restart_time, SmallDataIO::APPEND, first_step, ".dat");
means_file.remove_duplicate_time_data(); // removes any duplicate data from previous run (for checkpointing)

if(first_step)
{
means_file.write_header_line({"Scalar field mean","Scalar field variance","Pi mean","Scale factor","Conformal factor variance","Hubble factor",
"Kinetic ED","Potential ED","First SRP","Second SRP","Avg Ham constr","Avg |Ham| constr (point by point)","Avg Mom constr",
"Avg Ham abs term","Avg Mom abs term","Avg lapse"});
means_file.write_header_line({"SF mean ","SF variance ","Pi mean ","a ","chi variance ","H ",
"First SRP ","Second SRP ","|H| pbp norm ","M ","MAbs ","lapse ","shift 1 ","shift 2 ","shift 3"}); // "Kinetic ED ","Potential ED ", "Avg |Ham| constr (point by point) ","Avg Mom constr ",
//"Avg Ham abs term ","Avg Mom abs term ",
}
means_file.write_time_data_line({phibar, phivar, pibar, a, chivar, H, kinb, potb, epsilon, delta, hambar, hamabspbpSum, mombar, habsbar, mabsbar, lapse});
means_file.write_time_data_line({phibar, phivar, pibar, a, chivar, H, epsilon, delta, hamabspbpSum/habsbar, mombar, mabsbar, lapse,
shift[0], shift[1], shift[2]}); // kinb, potb,
}
6 changes: 3 additions & 3 deletions Examples/ScalarField/params.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
verbosity = 0

# location / naming of output files
output_path = "/home/eaf49/rds/hpc-work/hdf5-beta-check" # Main path for all files. Must exist!
output_path = "/home/eaf49/rds/hpc-work/dump" # Main path for all files. Must exist!
chk_prefix = ScalarField_
plot_prefix = ScalarFieldp_
# restart_file = ScalarField_002000.3d.hdf5
Expand All @@ -17,8 +17,8 @@ checkpoint_interval = 500
# set to 0 to turn off plot files (except at t=0 and t=stop_time)
# set to -1 to never ever print plotfiles
plot_interval = 100
num_plot_vars = 11
plot_vars = chi h11 h12 h13 h22 h23 h33 Ham Mom Ham_abs_terms Mom_abs_terms lapse shift1 shift2 shift3
num_plot_vars = 15
plot_vars = chi Ham Mom h11 h12 h13 h22 h23 h33 A11 A12 A13 A22 A23 A33

# subpaths - specific directories for hdf5, pout, extraction data
# (these are created at runtime)
Expand Down
21 changes: 8 additions & 13 deletions Source/InitialConditions/ScalarFields/RandomField.impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,13 @@
inline RandomField::RandomField(InitialScalarData::params_t a_params, std::string a_spec_type)
: m_params(a_params), m_spec_type(a_spec_type)
{
<<<<<<< HEAD
kstar = 16.*(2.*M_PI/m_params.L);
epsilon = 0.5;
=======
N = m_params.N;
debug = false;
kstar = 32.*(2.*M_PI/m_params.L);
epsilon = 0.05;
>>>>>>> IC-feature
kstar = 16.*(2.*M_PI/m_params.L);
epsilon = 0.5;
H0 = -3.0*sqrt((8.0 * M_PI/3.0/m_params.m_pl/m_params.m_pl)
*(0.5*m_params.velocity*m_params.velocity + 0.5*pow(m_params.m * m_params.amplitude, 2.0)));
norm = pow(m_params.N, 3.);
norm = pow(N, 3.);

calc_spectrum();
}
Expand Down Expand Up @@ -88,19 +83,19 @@ void RandomField::compute(Cell<data_t> current_cell) const

else if(m_spec_type == "velocity")
{
/*current_cell.store_vars(0., c_A11);
current_cell.store_vars(0., c_A11);
current_cell.store_vars(0., c_A12);
current_cell.store_vars(0., c_A13);
current_cell.store_vars(0., c_A22);
current_cell.store_vars(0., c_A23);
current_cell.store_vars(0., c_A33);*/
current_cell.store_vars(0., c_A33);

current_cell.store_vars(-m_params.A * hx[0][r], c_A11);
/*current_cell.store_vars(-m_params.A * hx[0][r], c_A11);
current_cell.store_vars(-m_params.A * hx[1][r], c_A12);
current_cell.store_vars(-m_params.A * hx[2][r], c_A13);
current_cell.store_vars(-m_params.A * hx[4][r], c_A22);
current_cell.store_vars(-m_params.A * hx[5][r], c_A23);
current_cell.store_vars(-m_params.A * hx[8][r], c_A33);
current_cell.store_vars(-m_params.A * hx[8][r], c_A33);*/
}

else { MayDay::Error("RandomField: Spec type entered is not a viable option."); }
Expand Down Expand Up @@ -256,7 +251,7 @@ void RandomField::calc_spectrum()
}

hkprint.close();
//MayDay::Error("Printed file for comparison with stand-alone IC generator.");
MayDay::Error("Printed file for comparison with stand-alone IC generator.");

pout() << "Moving to configuration space.\n";

Expand Down

0 comments on commit 5e0a986

Please sign in to comment.