diff --git a/src/hamiltonian/self_consistency.hpp b/src/hamiltonian/self_consistency.hpp index 1cade02e..72e7e151 100644 --- a/src/hamiltonian/self_consistency.hpp +++ b/src/hamiltonian/self_consistency.hpp @@ -158,6 +158,9 @@ class self_consistency { if(has_induced_vector_potential()){ hamiltonian.uniform_vector_potential_ += induced_vector_potential_; } + + //the magnetic perturbation is not implemented yet + assert(not pert_.has_magnetic_field()); } diff --git a/src/perturbations/blend.hpp b/src/perturbations/blend.hpp index 0a7deb74..b0264386 100644 --- a/src/perturbations/blend.hpp +++ b/src/perturbations/blend.hpp @@ -124,6 +124,21 @@ class blend { } } + auto has_magnetic_field() const { + for(auto & pert : perts_){ + auto has = std::visit([&](auto per) { return per.has_magnetic_field(); }, pert); + if(has) return true; + } + return false; + } + + template + void magnetic_field(double const time, MagneticField & magnetic) const { + for(auto & pert : perts_){ + std::visit([&](auto per) { per.magnetic_field(time, magnetic); }, pert); + } + } + void save(parallel::communicator & comm, std::string const & dirname) const { auto error_message = "INQ error: Cannot save the perturbations::blend to directory '" + dirname + "'."; diff --git a/src/perturbations/none.hpp b/src/perturbations/none.hpp index 685dd5cf..d56db847 100644 --- a/src/perturbations/none.hpp +++ b/src/perturbations/none.hpp @@ -47,6 +47,14 @@ class none { void potential(const double time, PotentialType & potential) const { } + auto has_magnetic_field() const { + return false; + } + + template + void magnetic_field(const double time, MagneticField & magnetic) const { + } + template friend OStream & operator<<(OStream & out, none const & self){ return out; diff --git a/src/perturbations/sum.hpp b/src/perturbations/sum.hpp index 5b2d856e..07a7be4f 100644 --- a/src/perturbations/sum.hpp +++ b/src/perturbations/sum.hpp @@ -65,7 +65,17 @@ class sum { perta_.potential(time, potential); pertb_.potential(time, potential); } + + auto has_magnetic_field() const { + return perta_.has_magnetic_field() or pertb_.has_magnetic_field(); + } + template + void magnetic_field(const double time, MagneticField & magnetic) const { + perta_.magnetic_field(time, magnetic); + pertb_.magnetic_field(time, magnetic); + } + template friend OStream & operator<<(OStream & out, sum const & self){ out << self.perta_;