From 0e25e4fabb3d941294bce40c6432ac2a93115eae Mon Sep 17 00:00:00 2001 From: Doak P W Date: Thu, 14 Dec 2023 11:42:08 -0500 Subject: [PATCH] additional hand merge from additional_dca_data_testing --- test/unit/phys/dca_data/dca_data_test.cpp | 80 ++++++++++++++++++++++- test/unit/phys/dca_data/input_adios2.json | 61 +++++++++++++++++ 2 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 test/unit/phys/dca_data/input_adios2.json diff --git a/test/unit/phys/dca_data/dca_data_test.cpp b/test/unit/phys/dca_data/dca_data_test.cpp index eac2bb173..69bd85bb5 100644 --- a/test/unit/phys/dca_data/dca_data_test.cpp +++ b/test/unit/phys/dca_data/dca_data_test.cpp @@ -105,6 +105,9 @@ struct DCADataTestWrapper : public ::testing::Test { constexpr char read_sigma_input_file[] = DCA_SOURCE_DIR "/test/unit/phys/dca_data/input_read_hdf5.json"; +constexpr char dca_data_test_adios2_input[] = + DCA_SOURCE_DIR "/test/unit/phys/dca_data/input_adios2.json"; + using DCADataTest = DCADataTestWrapper>; TEST_F(DCADataTest, ReadSigma) { @@ -112,6 +115,9 @@ TEST_F(DCADataTest, ReadSigma) { std::cout << "initial_self_energy:" << dca_setup_.parameters_->get_initial_self_energy(); dca_setup_.data_->initializeSigma("dca_data_test.hdf5"); EXPECT_EQ(dca_setup_.parameters_->get_chemical_potential(), 3.0); + decltype(dca_setup_.data_->Sigma) check_sigma("check_sigma"); + check_sigma = 3.0; + EXPECT_EQ(dca_setup_.data_->Sigma, check_sigma); } TEST_F(DCADataTest, ReadSigmaLegacy) { @@ -178,6 +184,7 @@ int main(int argc, char** argv) { dca_data.data_->initialize(); dca_data.loop_data_->chemical_potential(0) = 1.0; dca_data.loop_data_->last_completed_iteration = 0; + dca_data.data_->Sigma = 1.0; std::string format{"HDF5"}; dca::io::Writer writer( #ifdef DCA_HAVE_ADIOS2 @@ -191,19 +198,21 @@ int main(int argc, char** argv) { writer.end_step(); dca_data.loop_data_->chemical_potential(1) = 2.0; dca_data.loop_data_->last_completed_iteration = 1; + dca_data.data_->Sigma = 2.0; writer.begin_step(); dca_data.data_->write(writer); dca_data.loop_data_->write(writer, *concurrency_ptr); writer.end_step(); dca_data.loop_data_->chemical_potential(2) = 3.0; dca_data.loop_data_->last_completed_iteration = 2; + dca_data.data_->Sigma = 3.0; writer.begin_step(); dca_data.data_->write(writer); dca_data.loop_data_->write(writer, *concurrency_ptr); writer.end_step(); writer.close_file(); - // Fake legacy hdf5 file by omitting steps + // Fake legacy hdf5 file by omitting steps dca::io::Writer writer_legacy( #ifdef DCA_HAVE_ADIOS2 *adios_ptr, @@ -212,12 +221,81 @@ int main(int argc, char** argv) { writer_legacy.open_file("dca_data_test_legacy.hdf5", true); dca_data.loop_data_->chemical_potential(3) = 4.0; dca_data.loop_data_->last_completed_iteration = 3; + dca_data.data_->Sigma = 4.0; dca_data.data_->write(writer_legacy); dca_data.loop_data_->write(writer_legacy, *concurrency_ptr); auto& hdf5_writer = std::get(writer_legacy.getUnderlying()); // this writes without a top level steps variable hdf5_writer.legacy_close_file(); } +#ifdef DCA_HAVE_ADIOS2 + + { + // Make adioss file for testing. + DCADSetup dca_data; + dca_data.SetUp(concurrency_ptr); + dca_data.data_->initialize(); + dca_data.loop_data_->chemical_potential(0) = 1.0; + dca_data.loop_data_->last_completed_iteration = 0; + dca_data.data_->Sigma = 1.0; + std::string format{"ADIOS2"}; + dca::io::Writer writer(*adios_ptr, *concurrency_ptr, format); + writer.open_file("dca_data_test.bp", true); + //insure chemical potentials past the last complete iteration are ignored. + dca::io::Writer writer_extra_cpot( + *adios_ptr, + *concurrency_ptr, format); + writer_extra_cpot.open_file("dca_data_test_extra_cpot.bp", true); + //insure chemical potentials past the last complete iteration are ignored. + dca::io::Writer writer_another_cpot( + *adios_ptr, + *concurrency_ptr, format); + writer_another_cpot.open_file("dca_data_test_another_cpot.bp", true); + + std::vector>> writers{writer, writer_extra_cpot, writer_another_cpot}; + + auto begin_steps = [](dca::io::Writer& writer) { writer.begin_step(); }; + auto writes = [&dca_data](dca::io::Writer& writer) { dca_data.data_->write(writer); + dca_data.loop_data_->write(writer, *concurrency_ptr);}; + auto end_steps = [](dca::io::Writer& writer) { writer.end_step(); }; + + std::for_each(writers.begin(), writers.end(), begin_steps); + std::for_each(writers.begin(), writers.end(), writes); + std::for_each(writers.begin(), writers.end(), end_steps); + + dca_data.loop_data_->chemical_potential(1) = 2.0; + dca_data.loop_data_->last_completed_iteration = 1; + dca_data.data_->Sigma = 2.0; + std::for_each(writers.begin(), writers.end(), begin_steps); + std::for_each(writers.begin(), writers.end(), writes); + std::for_each(writers.begin(), writers.end(), end_steps); + + dca_data.loop_data_->chemical_potential(2) = 3.0; + dca_data.loop_data_->last_completed_iteration = 2; + dca_data.data_->Sigma = 3.0; + std::for_each(writers.begin(), writers.end(), begin_steps); + std::for_each(writers.begin(), writers.end(), writes); + std::for_each(writers.begin(), writers.end(), end_steps); + + + dca_data.loop_data_->chemical_potential(3) = 4.0; + dca_data.data_->Sigma = 4.0; + writer_extra_cpot.begin_step(); + dca_data.data_->write(writer_extra_cpot); + dca_data.loop_data_->write(writer_extra_cpot, *concurrency_ptr); + writer_extra_cpot.end_step(); + writer_extra_cpot.close_file(); + + + dca_data.loop_data_->last_completed_iteration = 3; + writer_another_cpot.begin_step(); + dca_data.data_->write(writer_another_cpot); + dca_data.loop_data_->write(writer_another_cpot, *concurrency_ptr); + writer_another_cpot.end_step(); + writer_another_cpot.close_file(); + } +#endif + int result = RUN_ALL_TESTS(); return result; } diff --git a/test/unit/phys/dca_data/input_adios2.json b/test/unit/phys/dca_data/input_adios2.json new file mode 100644 index 000000000..66339c46c --- /dev/null +++ b/test/unit/phys/dca_data/input_adios2.json @@ -0,0 +1,61 @@ +{ + "output" : + { + "output-format" : "ADIOS2", + "output-ED" : "ed_results.hdf5", + "output-QMC" : "output_QMC.hdf5" + }, + "physics" : + { + "beta" : 2, + "chemical-potential" : 0 + }, + "bilayer-Hubbard-model": + { + "t" : 1, + "U" : 2 + }, + "Hund-model": { + "t" : 1, + "U" : 1, + "V" : 1, + "Jh" : 2 + }, + "single-band-Hubbard-model": { + "t" : 1, + "U" : 2 + }, + "DCA": { + "iterations": 4 + }, + "domains": { + "real-space-grids": { + "cluster": [[2, 0], + [0, 2]] + }, + "imaginary-time": { + "sp-time-intervals": 512 + }, + "imaginary-frequency": { + "sp-fermionic-frequencies": 512, + "four-point-fermionic-frequencies" : 8 + } + }, + "four-point": { + "type": "NONE", + "momentum-transfer": [0., 3.1415], + "frequency-transfer": 2 + }, + "Monte-Carlo-integration" : { + "warm-up-sweeps" : 100, + "sweeps-per-measurement" : 1, + "measurements" : 500, + "seed" : 0 + }, + "CT-INT" : + { + "initial-configuration-size" :5, + "alpha-dd-pos" : 0.51, + "double-update-probability" : 0 + } +}