mirror of
https://github.com/triqs/dft_tools
synced 2024-12-25 13:53:40 +01:00
gf: add negative matsubara freqs
- add possibility of having negative matsubara freqs in the matsubara mesh. - TODO : finish imtime complex adapt fourier in this case test
This commit is contained in:
parent
255de834a2
commit
ce221dfc1c
@ -38,7 +38,8 @@ namespace gfs {
|
|||||||
: _dom(std::move(dom)), n_max(n_pts), _positive_only(positive_only) {}
|
: _dom(std::move(dom)), n_max(n_pts), _positive_only(positive_only) {}
|
||||||
|
|
||||||
domain_t const &domain() const { return _dom; }
|
domain_t const &domain() const { return _dom; }
|
||||||
size_t size() const { return (_positive_only ? n_max : 2 * n_max + 1); }
|
int index_start() const { return -(_positive_only ? 0 : n_max + (_dom.statistic == Fermion)); }
|
||||||
|
size_t size() const { return (_positive_only ? n_max : 2 * n_max + (_dom.statistic == Boson ? 1 : 2)); }
|
||||||
|
|
||||||
/// Conversions point <-> index <-> linear_index
|
/// Conversions point <-> index <-> linear_index
|
||||||
domain_pt_t index_to_point(index_t ind) const {
|
domain_pt_t index_to_point(index_t ind) const {
|
||||||
@ -46,21 +47,21 @@ namespace gfs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
size_t index_to_linear(index_t ind) const { return ind; }
|
int index_to_linear(index_t ind) const { return ind + index_start(); }
|
||||||
|
|
||||||
/// The wrapper for the mesh point
|
/// The mesh point
|
||||||
struct mesh_point_t : tag::mesh_point, matsubara_freq {
|
struct mesh_point_t : tag::mesh_point, matsubara_freq {
|
||||||
index_t n_max;
|
index_t index_start, index_stop;
|
||||||
mesh_point_t() = default;
|
mesh_point_t() = default;
|
||||||
mesh_point_t(matsubara_freq_mesh const &mesh, index_t const &index_)
|
mesh_point_t(matsubara_freq_mesh const &mesh, index_t const &index_)
|
||||||
: matsubara_freq(index_, mesh.domain().beta, mesh.domain().statistic), n_max(mesh.size()) {}
|
: matsubara_freq(index_, mesh.domain().beta, mesh.domain().statistic),
|
||||||
mesh_point_t(index_t const &index_, double beta_, statistic_enum stat_, index_t n_max_)
|
index_start(mesh.index_start()),
|
||||||
: matsubara_freq(index_, beta_, stat_), n_max(n_max_) {}
|
index_stop(mesh.index_start() + mesh.size() - 1) {}
|
||||||
void advance() { ++n; }
|
void advance() { ++n; }
|
||||||
size_t linear_index() const { return n; }
|
size_t linear_index() const { return n; }
|
||||||
size_t index() const { return n; }
|
size_t index() const { return n; }
|
||||||
bool at_end() const { return (n == n_max); }
|
bool at_end() const { return (n == index_stop); }
|
||||||
void reset() { n = 0; }
|
void reset() { n = index_start; }
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Accessing a point of the mesh
|
/// Accessing a point of the mesh
|
||||||
@ -84,12 +85,16 @@ namespace gfs {
|
|||||||
h5::group gr = fg.create_group(subgroup_name);
|
h5::group gr = fg.create_group(subgroup_name);
|
||||||
h5_write(gr, "domain", m.domain());
|
h5_write(gr, "domain", m.domain());
|
||||||
h5_write(gr, "size", m.size());
|
h5_write(gr, "size", m.size());
|
||||||
// h5_write(gr, "start_at_0", m._positive_only);
|
if (m._positive_only) {
|
||||||
// kept for backward compatibility
|
// h5_write(gr, "start_at_0", m._positive_only);
|
||||||
auto beta = m.domain().beta;
|
// kept for backward compatibility
|
||||||
h5_write(gr, "min", Fermion ? M_PI / beta : 0);
|
auto beta = m.domain().beta;
|
||||||
h5_write(gr, "max", ((Fermion ? 1 : 0) + 2 * m.size()) * M_PI / beta);
|
h5_write(gr, "min", Fermion ? M_PI / beta : 0);
|
||||||
h5_write(gr, "kind", 2);
|
h5_write(gr, "max", ((Fermion ? 1 : 0) + 2 * m.size()) * M_PI / beta);
|
||||||
|
h5_write(gr, "kind", 2);
|
||||||
|
} else { // A strange way : to preserve backward compatibility for old archive.
|
||||||
|
h5_write(gr, "start_at_0", m._positive_only);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Read from HDF5
|
/// Read from HDF5
|
||||||
@ -100,7 +105,7 @@ namespace gfs {
|
|||||||
bool s = true;
|
bool s = true;
|
||||||
h5_read(gr, "domain", dom);
|
h5_read(gr, "domain", dom);
|
||||||
h5_read(gr, "size", L);
|
h5_read(gr, "size", L);
|
||||||
// h5_read(gr, "start_at_0", s);
|
if (gr.has_key("start_at_0")) h5_read(gr, "start_at_0", s);
|
||||||
m = matsubara_freq_mesh{std::move(dom), L, s};
|
m = matsubara_freq_mesh{std::move(dom), L, s};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user