Skip to content

Commit

Permalink
Added random seed vector to RandomFields class, for an option to init…
Browse files Browse the repository at this point in the history
…ialise the field with multiple configurations
  • Loading branch information
the-florist committed Jul 3, 2024
1 parent 93744bb commit 3d0c565
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
12 changes: 6 additions & 6 deletions Examples/ScalarField/params.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
verbosity = 0

# location / naming of output files
output_path = "/home/eaf49/rds/hpc-work/dump" # Main path for all files. Must exist!
output_path = "/home/eaf49/rds/hpc-work/random-seed-test/config2" # Main path for all files. Must exist!
chk_prefix = ScalarField_
plot_prefix = ScalarFieldp_
# restart_file = ScalarField_001000.3d.hdf5

# HDF5files are written every dt = L/N*dt_multiplier*checkpoint_interval
checkpoint_interval = 500
checkpoint_interval = 300
# 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
plot_interval = 40
num_plot_vars = 6
plot_vars = h11 h12 h13 h22 h23 h33

Expand Down Expand Up @@ -57,7 +57,7 @@ tensor_amplitude = 1.
# NB - if you have a non-cubic grid, you can specify 'N1' or 'N1_full',
# 'N2' or 'N2_full' and 'N3' or 'N3_full' ( then dx_coarsest = L/N(max) )
# NB - the N values need to be multiples of the block_factor
N_full = 32
N_full = 64
L_full = 6.5

# Maximum number of times you can regrid above coarsest level
Expand Down Expand Up @@ -125,8 +125,8 @@ extrapolating_vars = phi Pi

# dt will be dx*dt_multiplier on each grid level
dt_multiplier = 0.25
stop_time = 10
max_steps = 2
stop_time = 40
max_steps = 1700

# Spatial derivative order (only affects CCZ4 RHS)
max_spatial_derivative_order = 4 # can be 4 or 6
Expand Down
21 changes: 17 additions & 4 deletions Source/InitialConditions/ScalarFields/RandomField.impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,9 @@ inline void RandomField::clear_data()
inline void RandomField::calc_spectrum()
{
int N = m_params.Nf;
std::string printdir = "/nfs/st01/hpc-gr-epss/eaf49/";

std::string printdir = "/home/eaf49/rds/hpc-work/";
int pair = 2;

// Setting the lut that maps polarisation vectors to
// polarisation tensors.
int lut[3][3];
Expand Down Expand Up @@ -210,9 +211,21 @@ inline void RandomField::calc_spectrum()
}

// Set up random number generators (one independent seed per random draw)
std::vector<int> seeds(10, 0);
seeds[0] = 3539263;
seeds[1] = 7586572;
seeds[2] = 5060982;
seeds[3] = 6793957;
seeds[4] = 4764135;
seeds[5] = 6961336;
seeds[6] = 2918557;
seeds[7] = 3024453;
seeds[8] = 5470767;
seeds[9] = 2125263;

int seed;
if(m_spec_type == "position") { seed = 3539263; }
else if(m_spec_type == "velocity") { seed = 7586572; }
if(m_spec_type == "position") { seed = seeds[2*pair]; }
else if(m_spec_type == "velocity") { seed = seeds[2*pair+1]; }
else { MayDay::Error("RandomField: Please choose either 'position' or 'velocity' field type."); }

default_random_engine engine(seed);
Expand Down

0 comments on commit 3d0c565

Please sign in to comment.