Skip to content

Commit

Permalink
additional hand merge from additional_dca_data_testing
Browse files Browse the repository at this point in the history
  • Loading branch information
PDoakORNL committed Dec 14, 2023
1 parent 26152c1 commit 0e25e4f
Show file tree
Hide file tree
Showing 2 changed files with 140 additions and 1 deletion.
80 changes: 79 additions & 1 deletion test/unit/phys/dca_data/dca_data_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,19 @@ 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<DCADSetup<read_sigma_input_file>>;

TEST_F(DCADataTest, ReadSigma) {
dca_setup_.data_->initialize();
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) {
Expand Down Expand Up @@ -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<Concurrency> writer(
#ifdef DCA_HAVE_ADIOS2
Expand All @@ -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<Concurrency> writer_legacy(
#ifdef DCA_HAVE_ADIOS2
*adios_ptr,
Expand All @@ -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<dca::io::HDF5Writer>(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_test_adios2_input> 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<Concurrency> 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<Concurrency> 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<Concurrency> writer_another_cpot(
*adios_ptr,
*concurrency_ptr, format);
writer_another_cpot.open_file("dca_data_test_another_cpot.bp", true);

std::vector<std::reference_wrapper<dca::io::Writer<Concurrency>>> writers{writer, writer_extra_cpot, writer_another_cpot};

auto begin_steps = [](dca::io::Writer<Concurrency>& writer) { writer.begin_step(); };
auto writes = [&dca_data](dca::io::Writer<Concurrency>& writer) { dca_data.data_->write(writer);
dca_data.loop_data_->write(writer, *concurrency_ptr);};
auto end_steps = [](dca::io::Writer<Concurrency>& 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;
}
61 changes: 61 additions & 0 deletions test/unit/phys/dca_data/input_adios2.json
Original file line number Diff line number Diff line change
@@ -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
}
}

0 comments on commit 0e25e4f

Please sign in to comment.