Commit c983c013 authored by Doak, Peter W.'s avatar Doak, Peter W.
Browse files

fix bug reading first chemical potential not last add test

parent 77c18a74
Loading
Loading
Loading
Loading
+11 −11
Original line number Diff line number Diff line
@@ -634,21 +634,21 @@ void DcaData<Parameters, DT>::initializeSigma(const std::string& filename) {
    std::size_t step_count = reader.getStepCount();
    // Work around odd way hdf5 steps get written
    int completed_iteration = 0;
  find_step:
    for (std::size_t i = 0; i < step_count; ++i) {
      reader.begin_step();
      std::cerr << "current step " << i << '\n';
      bool has_iteration =
          reader.execute("DCA-loop-functions/completed-iteration", completed_iteration);
      std::cerr << "completed_iteration " << completed_iteration << '\n';
      if (has_iteration && (i >= completed_iteration)) {
	std::cerr << "past complete iterations " << completed_iteration << "at step " << i << '\n';
      if (has_iteration)
	hdf5_last_iteration = completed_iteration;
      reader.end_step();
    }
    reader.close_file();
    reader.open_file(filename);
	step_count = hdf5_last_iteration;
	goto find_step;	
      }

    for (std::size_t i = 0; i < hdf5_last_iteration; ++i) {
	reader.begin_step();
	reader.end_step();
    }
    reader.begin_step();
@@ -664,10 +664,10 @@ void DcaData<Parameters, DT>::readSigmaFile(io::Reader<Concurrency>& reader) {
  reader.open_group("DCA-loop-functions");
  std::vector<double> chemical_potentials;
  bool chemical_potential_present = reader.execute("chemical-potential", chemical_potentials);
  int completed_iteration;
  bool has_iteration = reader.execute("completed-iteration", completed_iteration);
  
  std::vector<int> completed_iterations;
  bool has_iteration = reader.execute("completed-iteration", completed_iterations);
  if (chemical_potential_present && has_iteration) {
    int completed_iteration = *std::max_element(completed_iterations.begin(), completed_iterations.end());
    std::cout << "chemical-potential from Sigma file: " << chemical_potentials[completed_iteration]
              << '\n';
    parameters_.get_chemical_potential() = chemical_potentials[completed_iteration];
+0 −1
Original line number Diff line number Diff line
@@ -63,7 +63,6 @@ public:
  using k_HOST =
      func::dmn_0<domains::cluster_domain<double, ParametersType::lattice_type::DIMENSION, domains::LATTICE_SP,
                                          domains::MOMENTUM_SPACE, domains::BRILLOUIN_ZONE>>;

  using cluster_exclusion_type = clustermapping::cluster_exclusion<ParametersType, DcaDataType>;
  using double_counting_correction_type =
      clustermapping::double_counting_correction<ParametersType, DcaDataType>;
+1 −1
Original line number Diff line number Diff line
@@ -131,7 +131,7 @@ void update_chemical_potential<parameters_type, MOMS_type, coarsegraining_type>:
    double n_lb = lower_bound.second;
    double n_ub = upper_bound.second;

    parameters.get_chemical_potential() = get_new_chemical_potential(d_0, mu_lb, mu_ub, n_lb, n_ub);
    parameters.set_chemical_potential(get_new_chemical_potential(d_0, mu_lb, mu_ub, n_lb, n_ub));

    dens = compute_density();

+2 −0
Original line number Diff line number Diff line
@@ -51,6 +51,8 @@ public:
    return chemical_potential_;
  }

  void set_chemical_potential(double cpot) { chemical_potential_ = cpot; }

  bool adjust_chemical_potential() const {
    return adjust_chemical_potential_;
  }
+2 −1
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@

#include <cmath>  // M_PI
#include <stdexcept>
#include <iostream>

namespace dca {
namespace phys {
@@ -27,7 +28,7 @@ std::vector<int> frequency_domain::indices_;

void frequency_domain::initialize(const ScalarType beta, const int num_freqs) {
  if (initialized_)
    throw std::logic_error("frequency_domain has already been initialzed.");
    std::cerr << "frequency_domain has already been initialized., if this is not test code, this is likely a serious error!\n";

  const int size = 2 * num_freqs;

Loading