Skip to content
Snippets Groups Projects
Commit 54c10a82 authored by sniklas142's avatar sniklas142
Browse files

added testing for mode replacing function

parent e524c292
No related branches found
No related tags found
No related merge requests found
...@@ -61,34 +61,63 @@ template <typename rnumber> ...@@ -61,34 +61,63 @@ template <typename rnumber>
int ornstein_uhlenbeck_test<rnumber>::do_work(void) int ornstein_uhlenbeck_test<rnumber>::do_work(void)
{ {
TIMEZONE("ornstein_uhlenbeck_test::do_work"); TIMEZONE("ornstein_uhlenbeck_test::do_work");
std::string filename = this->simname + std::string("_fields.h5");
for (int step = 0; step < 10000; step++) for (int step = 0; step < 10000; step++)
{ {
this->ou->step(1e-3); this->ou->step(1e-3);
} }
hid_t out_file;
if (this->myrank == 0) { this->calc_stats();
out_file = H5Fopen("test_ou_output.h5", H5F_ACC_RDWR, H5P_DEFAULT); this->test_summation();
}
this->ou->kk->template cospectrum<rnumber,THREE>( return EXIT_SUCCESS;
this->ou->ou_field->get_cdata(), }
this->ou->ou_field->get_cdata(),
out_file,"ou_spectra",0);
this->ou->ou_field->symmetrize(); template <typename rnumber>
this->ou->ou_field->ift(); void ornstein_uhlenbeck_test<rnumber>::calc_stats(void)
std::vector<double> me; {
me.resize(3); TIMEZONE("ornstein_uhlenbeck_test::calc_stats");
std::fill(me.begin(),me.end(),30); field<rnumber,FFTW,THREE> *tmp_field = new field<rnumber,FFTW,THREE>(
// this->ou->ou_field->template compute_rspace_stats<rnumber, FFTW, THREE>(out_file, "ou", 0, me); this->nx,this->ny,this->nz, MPI_COMM_WORLD, FFTW_ESTIMATE);
this->ou->ou_field->compute_rspace_stats(out_file, "ou", 0, me); *tmp_field=0.0;
tmp_field->dft();
*tmp_field = *this->ou->ou_field;
std::cerr << tmp_field << " " << this->ou->ou_field << std::endl;
std::string filename = this->simname + std::string("_fields.h5");
hid_t out_file;
this->ou->ou_field->io("ou_field.h5", "ou_field", 0, false); if (this->myrank == 0) {
out_file = H5Fopen("test_ou_output.h5", H5F_ACC_RDWR, H5P_DEFAULT);
}
return EXIT_SUCCESS; this->ou->kk->template cospectrum<rnumber,THREE>(
tmp_field->get_cdata(),
tmp_field->get_cdata(),
out_file,"ou_spectra",0);
tmp_field->symmetrize(); //TODO necessary, not needed, introduce error?
tmp_field->ift();
std::vector<double> me;
me.resize(3);
std::fill(me.begin(),me.end(),3);
tmp_field->compute_rspace_stats(out_file, "ou", 0, me);
tmp_field->io("ou_field.h5", "ou_field", 0, false);
} }
template <typename rnumber>
void ornstein_uhlenbeck_test<rnumber>::test_summation()
{
field<rnumber,FFTW,THREE> *test_f = new field<rnumber,FFTW,THREE>(
this->nx,this->ny,this->nz, MPI_COMM_WORLD, FFTW_ESTIMATE);
*test_f = 0.0;
test_f->dft();
this->ou->add_to_field_replace(test_f);
test_f->symmetrize();
test_f->ift();
test_f->io("add_ou_test_field.h5", "ou_field", 0, false);
}
template class ornstein_uhlenbeck_test<float>; template class ornstein_uhlenbeck_test<float>;
template class ornstein_uhlenbeck_test<double>; template class ornstein_uhlenbeck_test<double>;
...@@ -21,7 +21,7 @@ class ornstein_uhlenbeck_test: public test { ...@@ -21,7 +21,7 @@ class ornstein_uhlenbeck_test: public test {
double ou_energy_amplitude; double ou_energy_amplitude;
ornstein_uhlenbeck_process<rnumber,FFTW> *ou; ornstein_uhlenbeck_process<rnumber,FFTW> *ou;
ornstein_uhlenbeck_test( ornstein_uhlenbeck_test(
const MPI_Comm COMMUNICATOR, const MPI_Comm COMMUNICATOR,
const std::string &simulation_name): const std::string &simulation_name):
...@@ -35,6 +35,10 @@ class ornstein_uhlenbeck_test: public test { ...@@ -35,6 +35,10 @@ class ornstein_uhlenbeck_test: public test {
int finalize(void); int finalize(void);
int read_parameters(void); int read_parameters(void);
void calc_stats(void);
void test_summation(void);
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment