From 0cf0263bed09b5f64ff35c92cd14f3e0ea7b3b38 Mon Sep 17 00:00:00 2001 From: Connor Glosser Date: Fri, 26 Oct 2018 22:50:21 -0400 Subject: [PATCH 01/43] Add .travis.yml file --- .travis.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..17d94855 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,13 @@ +language: cpp +compiler: + - clang + - gcc +addons: + apt: + sources: + - george-edison55-precise-backports + packages: + - cmake-data + - cmake + - libeigen3-dev + - libfftw3-dev From 52156fba0b2dcabf7765d1c780320fa984f34910 Mon Sep 17 00:00:00 2001 From: Connor Glosser Date: Fri, 26 Oct 2018 22:54:44 -0400 Subject: [PATCH 02/43] Update travis to build with cmake --- .travis.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.travis.yml b/.travis.yml index 17d94855..a81e3d57 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,14 @@ language: cpp compiler: - clang - gcc + +before_script: + - mkdir build + - cd build + - cmake .. + +script: make && make test + addons: apt: sources: From 5c14ee12272b14b910137eebf87a02a825c1f830 Mon Sep 17 00:00:00 2001 From: Connor Glosser Date: Fri, 26 Oct 2018 23:03:53 -0400 Subject: [PATCH 03/43] Get eigen package --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index a81e3d57..7e504b36 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,10 @@ before_script: script: make && make test +before_install: + - wget https://launchpad.net/ubuntu/+archive/primary/+files/libeigen3-dev_3.3.4-4build1_all.deb + - sudo dpkg -i libeigen3-dev_3.3.4-4build1_all.deb + addons: apt: sources: From 0d44ffb1c48f74d7bd71fdc4b672dea181f8d3a8 Mon Sep 17 00:00:00 2001 From: Connor Glosser Date: Fri, 26 Oct 2018 23:13:22 -0400 Subject: [PATCH 04/43] Remove eigen deb package; include boost dependencies --- .travis.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7e504b36..00785f86 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,10 +10,6 @@ before_script: script: make && make test -before_install: - - wget https://launchpad.net/ubuntu/+archive/primary/+files/libeigen3-dev_3.3.4-4build1_all.deb - - sudo dpkg -i libeigen3-dev_3.3.4-4build1_all.deb - addons: apt: sources: @@ -23,3 +19,5 @@ addons: - cmake - libeigen3-dev - libfftw3-dev + - libboost-test-dev + - libboost-program-options-dev \ No newline at end of file From 1357e2788a4cd004c3c3e62514b55b440ea24838 Mon Sep 17 00:00:00 2001 From: Connor Glosser Date: Fri, 26 Oct 2018 23:34:42 -0400 Subject: [PATCH 05/43] Manually get and build eigen package --- install/get_eigen.sh | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 install/get_eigen.sh diff --git a/install/get_eigen.sh b/install/get_eigen.sh new file mode 100644 index 00000000..52804864 --- /dev/null +++ b/install/get_eigen.sh @@ -0,0 +1,5 @@ +#!/bin/bash +wget https://bitbucket.org/eigen/eigen/get/3.3.2.tar.gz -O /tmp/eigen.tar.gz +tar -xvzf /tmp/eigen.tar.gz +mkdir -p eigen/build && tar -xvzf eigen.tar.gz -C eigen --strip-components 1 +cd eigen/build && cmake .. && make install \ No newline at end of file From 33fae634cfd56482aab6d2e9ca630013e3374d2f Mon Sep 17 00:00:00 2001 From: Connor Glosser Date: Fri, 26 Oct 2018 23:37:54 -0400 Subject: [PATCH 06/43] Actually run the eigen getter script --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 00785f86..4ce64f33 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,11 +4,12 @@ compiler: - gcc before_script: + - ./install/get_eigen.sh - mkdir build - cd build - cmake .. -script: make && make test +script: make qtest && ./qtest addons: apt: @@ -17,7 +18,6 @@ addons: packages: - cmake-data - cmake - - libeigen3-dev - libfftw3-dev - libboost-test-dev - libboost-program-options-dev \ No newline at end of file From d967f2ad872068cc14c8ae2adb03a6b76225f0fc Mon Sep 17 00:00:00 2001 From: Connor Glosser Date: Mon, 29 Oct 2018 21:44:56 -0400 Subject: [PATCH 07/43] Build Eigen with sudo --- .travis.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4ce64f33..f34cd120 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,9 +4,8 @@ compiler: - gcc before_script: - - ./install/get_eigen.sh - - mkdir build - - cd build + - sudo ./install/get_eigen.sh + - mkdir build && cd build - cmake .. script: make qtest && ./qtest @@ -20,4 +19,4 @@ addons: - cmake - libfftw3-dev - libboost-test-dev - - libboost-program-options-dev \ No newline at end of file + - libboost-program-options-dev From 7d9ee0f7c0c1c5cf0ede1dee2f233f3d74524b60 Mon Sep 17 00:00:00 2001 From: Connor Glosser Date: Mon, 29 Oct 2018 22:10:20 -0400 Subject: [PATCH 08/43] Fix up get eigen script --- install/get_eigen.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/install/get_eigen.sh b/install/get_eigen.sh index 52804864..ec104734 100644 --- a/install/get_eigen.sh +++ b/install/get_eigen.sh @@ -1,5 +1,5 @@ #!/bin/bash -wget https://bitbucket.org/eigen/eigen/get/3.3.2.tar.gz -O /tmp/eigen.tar.gz -tar -xvzf /tmp/eigen.tar.gz +cd /tmp +wget https://bitbucket.org/eigen/eigen/get/3.3.2.tar.gz -O eigen.tar.gz mkdir -p eigen/build && tar -xvzf eigen.tar.gz -C eigen --strip-components 1 -cd eigen/build && cmake .. && make install \ No newline at end of file +cd eigen/build && cmake .. && make install From 417f800bc3d448c23dabf92275d8269356389197 Mon Sep 17 00:00:00 2001 From: Connor Glosser Date: Mon, 29 Oct 2018 22:12:27 -0400 Subject: [PATCH 09/43] Mark as executable --- install/get_eigen.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 install/get_eigen.sh diff --git a/install/get_eigen.sh b/install/get_eigen.sh old mode 100644 new mode 100755 From a7bfe541833313b40d99ba4c4655b15de85a60d7 Mon Sep 17 00:00:00 2001 From: Connor Glosser Date: Mon, 29 Oct 2018 22:30:04 -0400 Subject: [PATCH 10/43] Get boost Too tired to write descriptive message --- .travis.yml | 1 + install/get_boost.sh | 7 +++++++ 2 files changed, 8 insertions(+) create mode 100755 install/get_boost.sh diff --git a/.travis.yml b/.travis.yml index f34cd120..dd31bf08 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ compiler: - gcc before_script: + - sudo ./install/get_boost.sh - sudo ./install/get_eigen.sh - mkdir build && cd build - cmake .. diff --git a/install/get_boost.sh b/install/get_boost.sh new file mode 100755 index 00000000..18d6c201 --- /dev/null +++ b/install/get_boost.sh @@ -0,0 +1,7 @@ +#!/bin/bash +cd /tmp +wget https://dl.bintray.com/boostorg/release/1.68.0/source/boost_1_68_0.tar.bz2 -O boost.tar.bz2 +mkdir -p boost && tar -xvf boost.tar.bz2 -C boost --strip-components 1 +cd boost/ +./bootstrap --with-libraries=program_options,test +./b2 install \ No newline at end of file From 91d6b8ace748dfef9394635785b148e43a0c9f0d Mon Sep 17 00:00:00 2001 From: Connor Glosser Date: Mon, 29 Oct 2018 22:36:49 -0400 Subject: [PATCH 11/43] Quiet logs --- .travis.yml | 4 ++-- install/get_boost.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index dd31bf08..c4310f2f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,8 +4,8 @@ compiler: - gcc before_script: - - sudo ./install/get_boost.sh - - sudo ./install/get_eigen.sh + - sudo ./install/get_boost.sh > /dev/null + - sudo ./install/get_eigen.sh > /dev/null - mkdir build && cd build - cmake .. diff --git a/install/get_boost.sh b/install/get_boost.sh index 18d6c201..43c5c622 100755 --- a/install/get_boost.sh +++ b/install/get_boost.sh @@ -4,4 +4,4 @@ wget https://dl.bintray.com/boostorg/release/1.68.0/source/boost_1_68_0.tar.bz2 mkdir -p boost && tar -xvf boost.tar.bz2 -C boost --strip-components 1 cd boost/ ./bootstrap --with-libraries=program_options,test -./b2 install \ No newline at end of file +./b2 install From eda915da551bcd2eb7cbc5644e6c9fa162e95b71 Mon Sep 17 00:00:00 2001 From: Connor Glosser Date: Fri, 2 Nov 2018 15:27:01 -0400 Subject: [PATCH 12/43] Debugging get boost --- install/get_boost.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/install/get_boost.sh b/install/get_boost.sh index 43c5c622..55d16edb 100755 --- a/install/get_boost.sh +++ b/install/get_boost.sh @@ -2,6 +2,7 @@ cd /tmp wget https://dl.bintray.com/boostorg/release/1.68.0/source/boost_1_68_0.tar.bz2 -O boost.tar.bz2 mkdir -p boost && tar -xvf boost.tar.bz2 -C boost --strip-components 1 +ls cd boost/ ./bootstrap --with-libraries=program_options,test ./b2 install From 32577f81c6d24580c96edfceb6df064848e70351 Mon Sep 17 00:00:00 2001 From: Connor Glosser Date: Fri, 2 Nov 2018 15:31:29 -0400 Subject: [PATCH 13/43] well crap. --- .travis.yml | 2 +- install/get_boost.sh | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c4310f2f..559e964d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: cpp compiler: - - clang + #- clang - gcc before_script: diff --git a/install/get_boost.sh b/install/get_boost.sh index 55d16edb..860ccfda 100755 --- a/install/get_boost.sh +++ b/install/get_boost.sh @@ -1,8 +1,13 @@ #!/bin/bash +echo "Changing to tmp" cd /tmp + +echo "Downloading and unpacking boost" wget https://dl.bintray.com/boostorg/release/1.68.0/source/boost_1_68_0.tar.bz2 -O boost.tar.bz2 mkdir -p boost && tar -xvf boost.tar.bz2 -C boost --strip-components 1 ls + +echo "Building boost" cd boost/ ./bootstrap --with-libraries=program_options,test ./b2 install From 28c92a0b703ecd8d4d266871a80c804a1acb8b54 Mon Sep 17 00:00:00 2001 From: Connor Glosser Date: Fri, 2 Nov 2018 15:37:25 -0400 Subject: [PATCH 14/43] changes --- install/get_boost.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/get_boost.sh b/install/get_boost.sh index 860ccfda..0b065cef 100755 --- a/install/get_boost.sh +++ b/install/get_boost.sh @@ -4,7 +4,7 @@ cd /tmp echo "Downloading and unpacking boost" wget https://dl.bintray.com/boostorg/release/1.68.0/source/boost_1_68_0.tar.bz2 -O boost.tar.bz2 -mkdir -p boost && tar -xvf boost.tar.bz2 -C boost --strip-components 1 +mkdir -p boost && tar -xvf boost.tar.bz2 -C boost --strip-components 1 > /dev/null ls echo "Building boost" From 75dce9f4187ae5db6ca0f2fd94be496ca6de78dc Mon Sep 17 00:00:00 2001 From: Thomas Bertus Date: Thu, 3 Oct 2019 16:52:15 -0400 Subject: [PATCH 15/43] formating --- src/pulse.cpp | 3 +-- src/quantum_dot.cpp | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/pulse.cpp b/src/pulse.cpp index 096d641c..6c9d83cf 100644 --- a/src/pulse.cpp +++ b/src/pulse.cpp @@ -22,8 +22,7 @@ Eigen::Vector3d Pulse::operator()(const Eigen::Vector3d &r, { const double arg = wavevector.dot(r) - freq * (t - delay); - Eigen::Vector3d pulse_vector; // is the convention to declare and define in - // the same line? + Eigen::Vector3d pulse_vector; pulse_vector = (amplitude / 2 * polarization) * gaussian(arg / width); pulse_vector *= rotating ? 1.0 : cos(arg); diff --git a/src/quantum_dot.cpp b/src/quantum_dot.cpp index 92a6ab89..f3575c32 100644 --- a/src/quantum_dot.cpp +++ b/src/quantum_dot.cpp @@ -20,7 +20,7 @@ matrix_elements QuantumDot::liouville_rhs(const matrix_elements &rho, m1_temp -= rotating ? iu * rho[1] * (laser_freq - freq) : iu * rho[1] * (-freq); - const cmplx m1 = m1_temp; // is this an appropriate way to do this? + const cmplx m1 = m1_temp; return matrix_elements(m0, m1); } From 2cec272b87b8813d0882137781b2de7f88bb3f90 Mon Sep 17 00:00:00 2001 From: Thomas Bertus Date: Tue, 19 May 2020 15:38:58 -0400 Subject: [PATCH 16/43] Eliminated redundant calls to bloch_rhs' evaluate during corrector steps --- src/integrator/RHS/bloch_rhs.cpp | 13 ++++---- src/integrator/RHS/bloch_rhs.h | 2 +- src/integrator/RHS/ode_rhs.h | 8 +++-- src/integrator/RHS/rhs.h | 2 +- src/integrator/integrator.h | 4 +-- src/interactions/AIM/aim_interaction.h | 5 ++-- src/interactions/AIM/direct.cpp | 40 +++++++++++++++---------- src/interactions/AIM/direct.h | 2 +- src/interactions/AIM/farfield.cpp | 30 ++++++++++++++----- src/interactions/AIM/farfield.h | 9 ++++-- src/interactions/AIM/nearfield.cpp | 39 ++++++++++++++++-------- src/interactions/AIM/nearfield.h | 2 +- src/interactions/direct_interaction.cpp | 40 +++++++++++++++---------- src/interactions/direct_interaction.h | 2 +- src/interactions/interaction.h | 10 +++++-- src/interactions/pulse_interaction.cpp | 2 +- src/interactions/pulse_interaction.h | 6 ++-- 17 files changed, 138 insertions(+), 78 deletions(-) diff --git a/src/integrator/RHS/bloch_rhs.cpp b/src/integrator/RHS/bloch_rhs.cpp index a2b041d1..1ff510dc 100644 --- a/src/integrator/RHS/bloch_rhs.cpp +++ b/src/integrator/RHS/bloch_rhs.cpp @@ -12,13 +12,13 @@ Integrator::BlochRHS::BlochRHS( { } -void Integrator::BlochRHS::evaluate(const int step) const +void Integrator::BlochRHS::evaluate(const int step, const bool first_call) const { - auto eval_and_sum = - [step](const InteractionBase::ResultArray &r, - const std::shared_ptr &interaction) { - return r + interaction->evaluate(step); - }; + auto eval_and_sum = [step, first_call]( + const InteractionBase::ResultArray &r, + const std::shared_ptr &interaction) { + return r + interaction->evaluate(step, first_call); + }; auto nil = InteractionBase::ResultArray::Zero(num_solutions, 1).eval(); auto projected_efields = std::accumulate( @@ -28,5 +28,4 @@ void Integrator::BlochRHS::evaluate(const int step) const history->array_[solution][step][1] = rhs_functions[solution]( history->array_[solution][step][0], projected_efields[solution]); } - } diff --git a/src/integrator/RHS/bloch_rhs.h b/src/integrator/RHS/bloch_rhs.h index 48bc2dd5..fb82a9dd 100644 --- a/src/integrator/RHS/bloch_rhs.h +++ b/src/integrator/RHS/bloch_rhs.h @@ -17,7 +17,7 @@ class Integrator::BlochRHS : public Integrator::RHS { const std::shared_ptr>, std::vector>, std::vector); - void evaluate(const int) const override; + void evaluate(const int, const bool = true) const override; private: int num_solutions; diff --git a/src/integrator/RHS/ode_rhs.h b/src/integrator/RHS/ode_rhs.h index 53595d97..a5892368 100644 --- a/src/integrator/RHS/ode_rhs.h +++ b/src/integrator/RHS/ode_rhs.h @@ -12,9 +12,10 @@ namespace Integrator { class Integrator::ODE_RHS : public RHS { public: - ODE_RHS(const double, const std::shared_ptr>, + ODE_RHS(const double, + const std::shared_ptr>, const std::vector>); - void evaluate(const int) const; + void evaluate(const int, const bool) const; private: std::vector> rhs_functions; @@ -28,7 +29,8 @@ Integrator::ODE_RHS::ODE_RHS( { } -void Integrator::ODE_RHS::evaluate(const int n) const +void Integrator::ODE_RHS::evaluate(const int n, + const bool first_call = true) const { const double time = n * dt; for(int i = 0; i < static_cast(history->array_.shape()[0]); ++i) { diff --git a/src/integrator/RHS/rhs.h b/src/integrator/RHS/rhs.h index aa04362d..9d0b8b9f 100644 --- a/src/integrator/RHS/rhs.h +++ b/src/integrator/RHS/rhs.h @@ -14,7 +14,7 @@ class Integrator::RHS { public: RHS(const double dt, const std::shared_ptr> history) : dt(dt), history(std::move(history)){}; - virtual void evaluate(const int) const = 0; + virtual void evaluate(const int, const bool = true) const = 0; protected: double dt; diff --git a/src/integrator/integrator.h b/src/integrator/integrator.h index fde0f683..53836ca6 100644 --- a/src/integrator/integrator.h +++ b/src/integrator/integrator.h @@ -76,11 +76,11 @@ void Integrator::PredictorCorrector::solve_step(const int step) const assert(0 <= step && step < time_idx_ubound); predictor(step); - rhs->evaluate(step); + rhs->evaluate(step, true); for(int m = 0; m < num_corrector_steps; ++m) { corrector(step); - rhs->evaluate(step); + rhs->evaluate(step, false); } } diff --git a/src/interactions/AIM/aim_interaction.h b/src/interactions/AIM/aim_interaction.h index 92c7758c..6ef894bd 100644 --- a/src/interactions/AIM/aim_interaction.h +++ b/src/interactions/AIM/aim_interaction.h @@ -58,11 +58,12 @@ class AIM::Interaction final : public InteractionBase { { } - const ResultArray &evaluate(const int t) + const ResultArray &evaluate(const int t, const bool first_call = true) { // I DON'T KNOW WHY THAT NEEDS A CONJUGATE!!! results = - (ff.evaluate(t).conjugate() - nf.evaluate(t)) + direct.evaluate(t); + (ff.evaluate(t, first_call).conjugate() - nf.evaluate(t, first_call)) + + direct.evaluate(t, first_call); return results; } diff --git a/src/interactions/AIM/direct.cpp b/src/interactions/AIM/direct.cpp index 88098b80..f132e424 100644 --- a/src/interactions/AIM/direct.cpp +++ b/src/interactions/AIM/direct.cpp @@ -18,28 +18,38 @@ AIM::DirectInteraction::DirectInteraction( } const InteractionBase::ResultArray &AIM::DirectInteraction::evaluate( - const int time_idx) + const int time_idx, const bool first_call) { - results.setZero(); + constexpr int RHO_01 = 1; + + temp_res.setZero(); + if(first_call) results.setZero(); for(int pair_idx = 0; pair_idx < shape_[0]; ++pair_idx) { const auto &pair = (*interaction_pairs_)[pair_idx]; - for(int i = 0; i < shape_[1]; ++i) { - const int s = - std::max(time_idx - floor_delays_[pair_idx] - i, - static_cast(history->array_.index_bases()[1])); - - constexpr int RHO_01 = 1; - - results[pair.first] += (history->array_[pair.second][s][0])[RHO_01] * - coefficients_[pair_idx][i]; - results[pair.second] += (history->array_[pair.first][s][0])[RHO_01] * - coefficients_[pair_idx][i]; + if(first_call) { + for(int i = 1; i < shape_[1]; ++i) { + const int s = + std::max(time_idx - floor_delays_[pair_idx] - i, + static_cast(history->array_.index_bases()[1])); + + results[pair.first] += (history->array_[pair.second][s][0])[RHO_01] * + coefficients_[pair_idx][i]; + results[pair.second] += (history->array_[pair.first][s][0])[RHO_01] * + coefficients_[pair_idx][i]; + } } - } + const int s = std::max(time_idx - floor_delays_[pair_idx], + static_cast(history->array_.index_bases()[1])); - return results; + temp_res[pair.first] += (history->array_[pair.second][s][0])[RHO_01] * + coefficients_[pair_idx][0]; + temp_res[pair.second] += (history->array_[pair.first][s][0])[RHO_01] * + coefficients_[pair_idx][0]; + } + temp_res += results; + return temp_res; } boost::multi_array AIM::DirectInteraction::coefficient_table( diff --git a/src/interactions/AIM/direct.h b/src/interactions/AIM/direct.h index 9f219e2c..73486bad 100644 --- a/src/interactions/AIM/direct.h +++ b/src/interactions/AIM/direct.h @@ -18,7 +18,7 @@ class AIM::DirectInteraction final : public HistoryInteraction { const double, std::shared_ptr>); - const ResultArray &evaluate(const int) final; + const ResultArray &evaluate(const int, const bool = true) final; boost::multi_array coefficient_table(Propagation::Kernel &, std::vector &) const; diff --git a/src/interactions/AIM/farfield.cpp b/src/interactions/AIM/farfield.cpp index 3525ad70..e7010706 100644 --- a/src/interactions/AIM/farfield.cpp +++ b/src/interactions/AIM/farfield.cpp @@ -63,7 +63,7 @@ void AIM::Farfield::fill_source_table(const int step) } } -void AIM::Farfield::propagate(const int step) +void AIM::Farfield::propagate(const int step, const bool first_call) { const auto wrapped_step = step % table_dimensions_[0]; const auto nb = 8 * grid->size(); @@ -76,17 +76,31 @@ void AIM::Farfield::propagate(const int step) Eigen::Map observers(&obs_table_(front), 3, nb); observers = 0; + // initialize temp_observers with the correct size and zero it + if(first_call) temp_observers = Eigen::Array3Xcd::Zero(3, nb); - for(int i = 0; i < table_dimensions_[0]; ++i) { - // If (step - i) runs "off the end", just propagate src[0][...] - auto wrap = std::max(step - i, 0) % table_dimensions_[0]; + if(first_call) { + // compute convolution up to but not including the current timestep + for(int i = 1; i < table_dimensions_[0]; ++i) { + // If (step - i) runs "off the end", just propagate src[0][...] + auto wrap = std::max(step - i, 0) % table_dimensions_[0]; - Eigen::Map prop(&propagation_table_[i][0][0][0], nb); - Eigen::Map src(&source_table_[wrap][0][0][0][0], 3, nb); + Eigen::Map prop(&propagation_table_[i][0][0][0], nb); + Eigen::Map src(&source_table_[wrap][0][0][0][0], 3, nb); - // Use broadcasting to do the x, y, and z component propagation - observers += src.rowwise() * prop.transpose(); + // Use broadcasting to do the x, y, and z component propagation + temp_observers += src.rowwise() * prop.transpose(); + } } + // set observers equal to temp_observers + // std::cout << temp_observers << "\n\n\n\n" << std::endl; + observers += temp_observers; + + auto wrap = std::max(step, 0) % table_dimensions_[0]; // needed ? + + Eigen::Map prop(&propagation_table_[0][0][0][0], nb); + Eigen::Map src(&source_table_[wrap][0][0][0][0], 3, nb); + observers += src.rowwise() * prop.transpose(); const auto o_ptr = &obs_table_(front); fftw_execute_dft(spatial_vector_transforms_.backward, diff --git a/src/interactions/AIM/farfield.h b/src/interactions/AIM/farfield.h index 95c90a3e..90ab8378 100644 --- a/src/interactions/AIM/farfield.h +++ b/src/interactions/AIM/farfield.h @@ -21,10 +21,11 @@ class AIM::Farfield final : public AimBase { Normalization::SpatialNorm); ~Farfield() = default; - const ResultArray &evaluate(const int step) final + const ResultArray &evaluate(const int step, + const bool first_call = true) final { fill_source_table(step); - propagate(step); + propagate(step, first_call); fill_results_table(step); return results; @@ -39,11 +40,13 @@ class AIM::Farfield final : public AimBase { spacetime::vector propagation_table_; spacetime::vector3d source_table_, obs_table_; + Eigen::Array3Xcd temp_observers; + TransformPair spatial_vector_transforms_; spacetime::vector make_propagation_table() const; void fill_source_table(const int); - void propagate(const int); + void propagate(const int, const bool); void fill_results_table(const int); void fill_gmatrix_table(spacetime::vector &) const; diff --git a/src/interactions/AIM/nearfield.cpp b/src/interactions/AIM/nearfield.cpp index 577c8642..f77dfd18 100644 --- a/src/interactions/AIM/nearfield.cpp +++ b/src/interactions/AIM/nearfield.cpp @@ -34,27 +34,42 @@ AIM::Nearfield::Nearfield( "calculations"); } -const InteractionBase::ResultArray &AIM::Nearfield::evaluate(const int time_idx) +const InteractionBase::ResultArray &AIM::Nearfield::evaluate( + const int time_idx, const bool first_call) { - results.setZero(); - constexpr int RHO_01 = 1; + constexpr int RH0_01 = 1; + + temp_res.setZero(); + if(first_call) results.setZero(); for(int pair_idx = 0; pair_idx < shape_[0]; ++pair_idx) { const auto &pair = (*interaction_pairs_)[pair_idx]; - for(int t = support_[pair_idx].begin; t < support_[pair_idx].end; ++t) { - const int s = std::max( - time_idx - t, static_cast(history->array_.index_bases()[1])); - - results[pair.first] += (history->array_[pair.second][s][0])[RHO_01] * - coefficients_[pair_idx][t][0]; + if(first_call) { + for(int t = support_[pair_idx].begin + 1; t < support_[pair_idx].end; + ++t) { + const int s = std::max( + time_idx - t, static_cast(history->array_.index_bases()[1])); - results[pair.second] += (history->array_[pair.first][s][0])[RHO_01] * - coefficients_[pair_idx][t][1]; + results[pair.first] += (history->array_[pair.second][s][0])[RHO_01] * + coefficients_[pair_idx][t][0]; + results[pair.second] += (history->array_[pair.first][s][0])[RHO_01] * + coefficients_[pair_idx][t][1]; + } } + int t = support_[pair_idx].begin; + const int s = std::max(time_idx - t, + static_cast(history->array_.index_bases()[1])); + assert(support_[pair_idx].begin == 0); + + temp_res[pair.first] += (history->array_[pair.second][s][0])[RHO_01] * + coefficients_[pair_idx][t][0]; + temp_res[pair.second] += (history->array_[pair.first][s][0])[RHO_01] * + coefficients_[pair_idx][t][1]; } + temp_res += results; - return results; + return temp_res; } boost::multi_array AIM::Nearfield::coefficient_table() diff --git a/src/interactions/AIM/nearfield.h b/src/interactions/AIM/nearfield.h index 38c3f87d..02ce3023 100644 --- a/src/interactions/AIM/nearfield.h +++ b/src/interactions/AIM/nearfield.h @@ -23,7 +23,7 @@ class AIM::Nearfield final : public AimBase { const double = 0); ~Nearfield() = default; - const ResultArray &evaluate(const int) final; + const ResultArray &evaluate(const int, const bool = true) final; private: struct support_range_t { diff --git a/src/interactions/direct_interaction.cpp b/src/interactions/direct_interaction.cpp index 001e5ae0..1c0ae79d 100644 --- a/src/interactions/direct_interaction.cpp +++ b/src/interactions/direct_interaction.cpp @@ -43,29 +43,39 @@ void DirectInteraction::build_coefficient_table( } const InteractionBase::ResultArray &DirectInteraction::evaluate( - const int time_idx) + const int time_idx, const bool first_call) { - results.setZero(); + constexpr int RHO_01 = 1; + temp_res.setZero(); + if(first_call) results.setZero(); + // iterate through all dot pairs for(int pair_idx = 0; pair_idx < num_interactions; ++pair_idx) { int src, obs; std::tie(src, obs) = idx2coord(pair_idx); - for(int i = 0; i <= interp_order; ++i) { - const int s = - std::max(time_idx - floor_delays[pair_idx] - i, - static_cast(history->array_.index_bases()[1])); - - constexpr int RHO_01 = 1; - - results[src] += - (history->array_[obs][s][0])[RHO_01] * coefficients[pair_idx][i]; - results[obs] += - (history->array_[src][s][0])[RHO_01] * coefficients[pair_idx][i]; + if(first_call) { // sum over history if this is the first call + for(int i = 1; i <= interp_order; ++i) { + const int s = + std::max(time_idx - floor_delays[pair_idx] - i, + static_cast(history->array_.index_bases()[1])); + + results[src] += + (history->array_[obs][s][0])[RHO_01] * coefficients[pair_idx][i]; + results[obs] += + (history->array_[src][s][0])[RHO_01] * coefficients[pair_idx][i]; + } } - } + const int s = std::max(time_idx - floor_delays[pair_idx], + static_cast(history->array_.index_bases()[1])); - return results; + temp_res[src] += + (history->array_[obs][s][0])[RHO_01] * coefficients[pair_idx][0]; + temp_res[obs] += + (history->array_[src][s][0])[RHO_01] * coefficients[pair_idx][0]; + } + temp_res += results; + return temp_res; } int DirectInteraction::coord2idx(int row, int col) diff --git a/src/interactions/direct_interaction.h b/src/interactions/direct_interaction.h index c2e421a1..4d1f7a0e 100644 --- a/src/interactions/direct_interaction.h +++ b/src/interactions/direct_interaction.h @@ -13,7 +13,7 @@ class DirectInteraction final : public HistoryInteraction { const double, const double); - const ResultArray &evaluate(const int) final; + const ResultArray &evaluate(const int, const bool = true) final; private: int num_interactions; diff --git a/src/interactions/interaction.h b/src/interactions/interaction.h index aee5d798..ac029ebe 100644 --- a/src/interactions/interaction.h +++ b/src/interactions/interaction.h @@ -11,14 +11,18 @@ class InteractionBase { typedef Eigen::Array ResultArray; InteractionBase(const std::shared_ptr dots, const double dt) - : dots(std::move(dots)), results(dots ? dots->size() : 0), dt(dt){}; - const cmplx &operator[](const int i) const { return results[i]; } - virtual const ResultArray &evaluate(const int) = 0; + : dots(std::move(dots)), + results(dots ? dots->size() : 0), + temp_res(dots ? dots->size() : 0), + dt(dt){}; + // const cmplx &operator[](const int i) const { return results[i]; } + virtual const ResultArray &evaluate(const int, const bool = true) = 0; virtual ~InteractionBase(){}; protected: std::shared_ptr dots; ResultArray results; + ResultArray temp_res; double dt; }; diff --git a/src/interactions/pulse_interaction.cpp b/src/interactions/pulse_interaction.cpp index 7ba801c6..3cc1fabc 100644 --- a/src/interactions/pulse_interaction.cpp +++ b/src/interactions/pulse_interaction.cpp @@ -9,7 +9,7 @@ PulseInteraction::PulseInteraction(const std::shared_ptr dots, } const InteractionBase::ResultArray &PulseInteraction::evaluate( - const int time_idx) + const int time_idx, const bool first_call) { const double time = time_idx * dt; diff --git a/src/interactions/pulse_interaction.h b/src/interactions/pulse_interaction.h index 86c217cf..3b3b33ee 100644 --- a/src/interactions/pulse_interaction.h +++ b/src/interactions/pulse_interaction.h @@ -7,8 +7,10 @@ class PulseInteraction : public InteractionBase { public: PulseInteraction(const std::shared_ptr, - const std::shared_ptr, const double, const double); - virtual const ResultArray &evaluate(const int); + const std::shared_ptr, + const double, + const double); + virtual const ResultArray &evaluate(const int, const bool = true); private: std::shared_ptr pulse; From 6ba5f6f456fd77403a294f9136b9d1831c3fafb7 Mon Sep 17 00:00:00 2001 From: Thomas Bertus Date: Tue, 26 May 2020 17:10:20 -0400 Subject: [PATCH 17/43] the way to win on rainbow road --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 559e964d..eeab3dbf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ compiler: - gcc before_script: - - sudo ./install/get_boost.sh > /dev/null + - sudo ./install/get_boost.sh # > /dev/null - sudo ./install/get_eigen.sh > /dev/null - mkdir build && cd build - cmake .. From 9961c14f453bbcd1593371e2b057d0d75df4f39c Mon Sep 17 00:00:00 2001 From: Thomas Bertus Date: Tue, 26 May 2020 17:15:37 -0400 Subject: [PATCH 18/43] listing what's in the boost directory --- install/get_boost.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/install/get_boost.sh b/install/get_boost.sh index 0b065cef..3f79d404 100755 --- a/install/get_boost.sh +++ b/install/get_boost.sh @@ -9,5 +9,6 @@ ls echo "Building boost" cd boost/ +ls ./bootstrap --with-libraries=program_options,test ./b2 install From 492cb9cd1b09d5d074d3c9f1a30d8d7b2eb6a818 Mon Sep 17 00:00:00 2001 From: Thomas Bertus Date: Tue, 26 May 2020 17:25:24 -0400 Subject: [PATCH 19/43] added .sh to ./bootstrap.sh in get_boost.sh --- .travis.yml | 2 +- install/get_boost.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index eeab3dbf..559e964d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ compiler: - gcc before_script: - - sudo ./install/get_boost.sh # > /dev/null + - sudo ./install/get_boost.sh > /dev/null - sudo ./install/get_eigen.sh > /dev/null - mkdir build && cd build - cmake .. diff --git a/install/get_boost.sh b/install/get_boost.sh index 3f79d404..25412f3f 100755 --- a/install/get_boost.sh +++ b/install/get_boost.sh @@ -10,5 +10,5 @@ ls echo "Building boost" cd boost/ ls -./bootstrap --with-libraries=program_options,test +./bootstrap.sh --with-libraries=program_options,test ./b2 install From 616d85e3e39bea5d2cba1ac14e56bc0ba96ef594 Mon Sep 17 00:00:00 2001 From: Thomas Bertus Date: Tue, 26 May 2020 18:05:18 -0400 Subject: [PATCH 20/43] changed make qtest to make qtest-bin and commented out anything related to rapidcheck --- .travis.yml | 2 +- test/CMakeLists.txt | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 559e964d..ee6619c4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ before_script: - mkdir build && cd build - cmake .. -script: make qtest && ./qtest +script: make qtest-bin && ./qtest addons: apt: diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 2f45584b..181a51f7 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -12,14 +12,15 @@ if(${Boost_FOUND}) PUBLIC "${CMAKE_CURRENT_LIST_DIR}/integrator_test.cpp" "${CMAKE_CURRENT_LIST_DIR}/lagrange_set_test.cpp" - "${CMAKE_CURRENT_LIST_DIR}/math_utils_test.cpp" + #"${CMAKE_CURRENT_LIST_DIR}/math_utils_test.cpp" + # TODO: fix the issues with rapidcheck "${CMAKE_CURRENT_LIST_DIR}/propagator_test.cpp" "${CMAKE_CURRENT_LIST_DIR}/pulse_interaction_test.cpp" "${CMAKE_CURRENT_LIST_DIR}/quantum_dot_test.cpp" ) - add_subdirectory("extras/rapidcheck") - add_subdirectory("extras/rapidcheck/extras/boost_test") + #add_subdirectory("extras/rapidcheck") + #add_subdirectory("extras/rapidcheck/extras/boost_test") - target_link_libraries(qtest-bin PUBLIC quest ${Boost_LIBRARIES} rapidcheck rapidcheck_boost_test) + target_link_libraries(qtest-bin PUBLIC quest ${Boost_LIBRARIES})# rapidcheck rapidcheck_boost_test) endif(${Boost_FOUND}) From 102ceb13d9e56ea10be37fb2207f951157419848 Mon Sep 17 00:00:00 2001 From: Thomas Bertus Date: Tue, 26 May 2020 19:48:16 -0400 Subject: [PATCH 21/43] trying to get rapidcheck to work. submodules are pretty cool --- test/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 181a51f7..31e722f5 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -12,15 +12,15 @@ if(${Boost_FOUND}) PUBLIC "${CMAKE_CURRENT_LIST_DIR}/integrator_test.cpp" "${CMAKE_CURRENT_LIST_DIR}/lagrange_set_test.cpp" - #"${CMAKE_CURRENT_LIST_DIR}/math_utils_test.cpp" + "${CMAKE_CURRENT_LIST_DIR}/math_utils_test.cpp" # TODO: fix the issues with rapidcheck "${CMAKE_CURRENT_LIST_DIR}/propagator_test.cpp" "${CMAKE_CURRENT_LIST_DIR}/pulse_interaction_test.cpp" "${CMAKE_CURRENT_LIST_DIR}/quantum_dot_test.cpp" ) - #add_subdirectory("extras/rapidcheck") - #add_subdirectory("extras/rapidcheck/extras/boost_test") + add_subdirectory("extras/rapidcheck") + add_subdirectory("extras/rapidcheck/extras/boost_test") - target_link_libraries(qtest-bin PUBLIC quest ${Boost_LIBRARIES})# rapidcheck rapidcheck_boost_test) + target_link_libraries(qtest-bin PUBLIC quest ${Boost_LIBRARIES} rapidcheck rapidcheck_boost_test) endif(${Boost_FOUND}) From 7cbdc2344ef6e550beb5f1b4f23464667c4acd85 Mon Sep 17 00:00:00 2001 From: Thomas Bertus Date: Tue, 26 May 2020 21:04:44 -0400 Subject: [PATCH 22/43] automatic boost install --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ee6619c4..3f7cb000 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ compiler: - gcc before_script: - - sudo ./install/get_boost.sh > /dev/null + # - sudo ./install/get_boost.sh > /dev/null - sudo ./install/get_eigen.sh > /dev/null - mkdir build && cd build - cmake .. From 10c54d839d58826f324c6793a67bef2a10b9e383 Mon Sep 17 00:00:00 2001 From: Thomas Bertus Date: Tue, 26 May 2020 21:19:29 -0400 Subject: [PATCH 23/43] trying to install boost automatically --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 3f7cb000..57c3399a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,6 +18,7 @@ addons: packages: - cmake-data - cmake + - boost1.68 - libfftw3-dev - libboost-test-dev - libboost-program-options-dev From 96ebe23e4cafef02c1a63e164777823cf88aef57 Mon Sep 17 00:00:00 2001 From: Thomas Bertus Date: Tue, 26 May 2020 21:49:34 -0400 Subject: [PATCH 24/43] other changes --- .travis.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 57c3399a..39f22015 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ compiler: - gcc before_script: - # - sudo ./install/get_boost.sh > /dev/null + - sudo ./install/get_boost.sh > /dev/null - sudo ./install/get_eigen.sh > /dev/null - mkdir build && cd build - cmake .. @@ -18,7 +18,6 @@ addons: packages: - cmake-data - cmake - - boost1.68 - libfftw3-dev - - libboost-test-dev - - libboost-program-options-dev + #- libboost-test-dev + #- libboost-program-options-dev From 8ccb2f0f7d14c57bf6069069d565f1bccf24f5ca Mon Sep 17 00:00:00 2001 From: Thomas Bertus Date: Tue, 26 May 2020 23:57:18 -0400 Subject: [PATCH 25/43] temporarily removed some unit tests --- test/AIM/CMakeLists.txt | 2 +- test/CMakeLists.txt | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/test/AIM/CMakeLists.txt b/test/AIM/CMakeLists.txt index e884af67..117470cb 100644 --- a/test/AIM/CMakeLists.txt +++ b/test/AIM/CMakeLists.txt @@ -5,6 +5,6 @@ target_sources(qtest-bin "${CMAKE_CURRENT_LIST_DIR}/grid_test.cpp" "${CMAKE_CURRENT_LIST_DIR}/spacetime_test.cpp" - "${CMAKE_CURRENT_LIST_DIR}/farfield_test.cpp" + #"${CMAKE_CURRENT_LIST_DIR}/farfield_test.cpp" "${CMAKE_CURRENT_LIST_DIR}/field_tests.cpp" ) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 31e722f5..2f45584b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -13,7 +13,6 @@ if(${Boost_FOUND}) "${CMAKE_CURRENT_LIST_DIR}/integrator_test.cpp" "${CMAKE_CURRENT_LIST_DIR}/lagrange_set_test.cpp" "${CMAKE_CURRENT_LIST_DIR}/math_utils_test.cpp" - # TODO: fix the issues with rapidcheck "${CMAKE_CURRENT_LIST_DIR}/propagator_test.cpp" "${CMAKE_CURRENT_LIST_DIR}/pulse_interaction_test.cpp" "${CMAKE_CURRENT_LIST_DIR}/quantum_dot_test.cpp" From d331aff977716dddf7d0a789817026084b950afc Mon Sep 17 00:00:00 2001 From: Thomas Bertus Date: Wed, 27 May 2020 00:04:45 -0400 Subject: [PATCH 26/43] temporarily removed some unit tests --- test/AIM/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/AIM/CMakeLists.txt b/test/AIM/CMakeLists.txt index 117470cb..9ae97859 100644 --- a/test/AIM/CMakeLists.txt +++ b/test/AIM/CMakeLists.txt @@ -5,6 +5,6 @@ target_sources(qtest-bin "${CMAKE_CURRENT_LIST_DIR}/grid_test.cpp" "${CMAKE_CURRENT_LIST_DIR}/spacetime_test.cpp" - #"${CMAKE_CURRENT_LIST_DIR}/farfield_test.cpp" - "${CMAKE_CURRENT_LIST_DIR}/field_tests.cpp" + "${CMAKE_CURRENT_LIST_DIR}/farfield_test.cpp" + #"${CMAKE_CURRENT_LIST_DIR}/field_tests.cpp" ) From 42db27ebd9af0bd73148265f754097ec04d666dd Mon Sep 17 00:00:00 2001 From: Thomas Bertus Date: Wed, 27 May 2020 11:46:48 -0400 Subject: [PATCH 27/43] installing eigen through apt --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 39f22015..bf878889 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ compiler: before_script: - sudo ./install/get_boost.sh > /dev/null - - sudo ./install/get_eigen.sh > /dev/null + #- sudo ./install/get_eigen.sh > /dev/null - mkdir build && cd build - cmake .. @@ -19,5 +19,6 @@ addons: - cmake-data - cmake - libfftw3-dev + - libeigen3-dev #- libboost-test-dev #- libboost-program-options-dev From 85d3b3ffabf83e94428919f13b6619d3d47fc26a Mon Sep 17 00:00:00 2001 From: Thomas Bertus Date: Wed, 27 May 2020 11:56:04 -0400 Subject: [PATCH 28/43] boost / eigen versions available through apt do not work well with rapidcheck and/or qtest --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index bf878889..c2a812d1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ compiler: before_script: - sudo ./install/get_boost.sh > /dev/null - #- sudo ./install/get_eigen.sh > /dev/null + - sudo ./install/get_eigen.sh > /dev/null - mkdir build && cd build - cmake .. @@ -19,6 +19,6 @@ addons: - cmake-data - cmake - libfftw3-dev - - libeigen3-dev + #- libeigen3-dev #- libboost-test-dev #- libboost-program-options-dev From 9fe8f2fd05fd20a0b78a9137cfbc1e6964dc988c Mon Sep 17 00:00:00 2001 From: Thomas Bertus Date: Fri, 29 May 2020 15:28:27 -0400 Subject: [PATCH 29/43] added pass/fail flag to README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b30cb600..7932c4be 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ [![DOI](https://zenodo.org/badge/37320094.svg)](https://zenodo.org/badge/latestdoi/37320094) +[![Build Status](https://travis-ci.org/tbertus/QuEST.svg?branch=development)] [![Article](https://img.shields.io/badge/article-Phys.%20Rev.%20A%2096%2C%20033816-B10DC9.svg)](https://journals.aps.org/pra/abstract/10.1103/PhysRevA.96.033816) # QuEST: The Quantum Electromagnetics Simulation Toolbox From c23b7525dc6c60ee7b2fa6d9b17d8cc5ed4fed64 Mon Sep 17 00:00:00 2001 From: Thomas Bertus Date: Fri, 29 May 2020 15:32:20 -0400 Subject: [PATCH 30/43] working on badg --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7932c4be..5278c90e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![DOI](https://zenodo.org/badge/37320094.svg)](https://zenodo.org/badge/latestdoi/37320094) -[![Build Status](https://travis-ci.org/tbertus/QuEST.svg?branch=development)] +[![DOI](https://zenodo.org/badge/37320094.svg)](https://zenodo.org/badge/latestdoi/37320094) [![Build Status](https://travis-ci.org/tbertus/QuEST.svg?branch=development)](https://travis-ci.org/tbertus/QuEST) + [![Article](https://img.shields.io/badge/article-Phys.%20Rev.%20A%2096%2C%20033816-B10DC9.svg)](https://journals.aps.org/pra/abstract/10.1103/PhysRevA.96.033816) # QuEST: The Quantum Electromagnetics Simulation Toolbox From f8777e0480968878dd2daf40a85560338a178659 Mon Sep 17 00:00:00 2001 From: Thomas Bertus Date: Fri, 29 May 2020 15:34:42 -0400 Subject: [PATCH 31/43] markdown troubles --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5278c90e..d673681f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![DOI](https://zenodo.org/badge/37320094.svg)](https://zenodo.org/badge/latestdoi/37320094) [![Build Status](https://travis-ci.org/tbertus/QuEST.svg?branch=development)](https://travis-ci.org/tbertus/QuEST) +[![DOI](https://zenodo.org/badge/37320094.svg)](https://zenodo.org/badge/latestdoi/37320094) [![Build Status](https://travis-ci.org/tbertus/QuEST.svg?branch=development)](https://travis-ci.org/tbertus/QuEST/branch/development) [![Article](https://img.shields.io/badge/article-Phys.%20Rev.%20A%2096%2C%20033816-B10DC9.svg)](https://journals.aps.org/pra/abstract/10.1103/PhysRevA.96.033816) From 7e5be99379e8f2b3ae00823ffedefebacbb9f70f Mon Sep 17 00:00:00 2001 From: Thomas Bertus Date: Fri, 29 May 2020 15:51:59 -0400 Subject: [PATCH 32/43] try to get submodule to work with travis --- .gitmodules | 3 --- README.md | 2 +- extras/rapidcheck | 1 - rapidcheck | 1 - 4 files changed, 1 insertion(+), 6 deletions(-) delete mode 160000 extras/rapidcheck delete mode 160000 rapidcheck diff --git a/.gitmodules b/.gitmodules index ba49ca9b..e69de29b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "extra/rapidcheck"] - path = extras/rapidcheck - url = https://github.com/emil-e/rapidcheck.git diff --git a/README.md b/README.md index d673681f..dfba7d73 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![DOI](https://zenodo.org/badge/37320094.svg)](https://zenodo.org/badge/latestdoi/37320094) [![Build Status](https://travis-ci.org/tbertus/QuEST.svg?branch=development)](https://travis-ci.org/tbertus/QuEST/branch/development) +[![Build Status](https://travis-ci.org/tbertus/QuEST.svg?branch=development)](https://travis-ci.org/tbertus/QuEST/branch/development) [![DOI](https://zenodo.org/badge/37320094.svg)](https://zenodo.org/badge/latestdoi/37320094) [![Article](https://img.shields.io/badge/article-Phys.%20Rev.%20A%2096%2C%20033816-B10DC9.svg)](https://journals.aps.org/pra/abstract/10.1103/PhysRevA.96.033816) diff --git a/extras/rapidcheck b/extras/rapidcheck deleted file mode 160000 index 624fe9a3..00000000 --- a/extras/rapidcheck +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 624fe9a32ece0d749745036c5b4c64e2308be595 diff --git a/rapidcheck b/rapidcheck deleted file mode 160000 index d9482c68..00000000 --- a/rapidcheck +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d9482c683429fe79122e3dcab14c9655874aeb8e From afed5c6b387a2ad7f906973aadde1ed7afcefd75 Mon Sep 17 00:00:00 2001 From: Thomas Bertus Date: Fri, 29 May 2020 16:14:04 -0400 Subject: [PATCH 33/43] initialize rapidcheck submodule --- .gitmodules | 3 +++ rapidcheck | 1 + 2 files changed, 4 insertions(+) create mode 160000 rapidcheck diff --git a/.gitmodules b/.gitmodules index e69de29b..4fc2013e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "rapidcheck"] + path = rapidcheck + url = https://github.com/emil-e/rapidcheck.git diff --git a/rapidcheck b/rapidcheck new file mode 160000 index 00000000..7bc7d302 --- /dev/null +++ b/rapidcheck @@ -0,0 +1 @@ +Subproject commit 7bc7d302191a4f3d0bf005692677126136e02f60 From 17697fb5b75cacca2a6bc75971ce33e71739f3d4 Mon Sep 17 00:00:00 2001 From: Thomas Bertus Date: Mon, 1 Jun 2020 19:51:59 -0400 Subject: [PATCH 34/43] removed first_call flag in favor of two seperate functions --- src/integrator/RHS/bloch_rhs.cpp | 26 +++++- src/integrator/RHS/bloch_rhs.h | 3 +- src/integrator/RHS/ode_rhs.h | 11 ++- src/integrator/RHS/rhs.h | 3 +- src/integrator/integrator.h | 4 +- src/interactions/AIM/aim_interaction.h | 13 ++- src/interactions/AIM/direct.cpp | 98 ++++++++++++++++----- src/interactions/AIM/direct.h | 3 +- src/interactions/AIM/farfield.cpp | 97 ++++++++++++++++++--- src/interactions/AIM/farfield.h | 15 +++- src/interactions/AIM/nearfield.cpp | 108 ++++++++++++++++++------ src/interactions/AIM/nearfield.h | 3 +- src/interactions/direct_interaction.cpp | 96 ++++++++++++++++----- src/interactions/direct_interaction.h | 3 +- src/interactions/interaction.h | 8 +- src/interactions/pulse_interaction.cpp | 2 +- src/interactions/pulse_interaction.h | 6 +- test/propagator_test.cpp | 8 +- 18 files changed, 404 insertions(+), 103 deletions(-) diff --git a/src/integrator/RHS/bloch_rhs.cpp b/src/integrator/RHS/bloch_rhs.cpp index 1ff510dc..0621195c 100644 --- a/src/integrator/RHS/bloch_rhs.cpp +++ b/src/integrator/RHS/bloch_rhs.cpp @@ -12,13 +12,33 @@ Integrator::BlochRHS::BlochRHS( { } -void Integrator::BlochRHS::evaluate(const int step, const bool first_call) const +void Integrator::BlochRHS::evaluate(const int step) const { - auto eval_and_sum = [step, first_call]( + auto eval_and_sum = [step]( const InteractionBase::ResultArray &r, const std::shared_ptr &interaction) { - return r + interaction->evaluate(step, first_call); + return r + interaction->evaluate(step); }; + // TODO: change the evaluate function here to two seperate functions + auto nil = InteractionBase::ResultArray::Zero(num_solutions, 1).eval(); + + auto projected_efields = std::accumulate( + interactions.begin(), interactions.end(), nil, eval_and_sum); + + for(int solution = 0; solution < num_solutions; ++solution) { + history->array_[solution][step][1] = rhs_functions[solution]( + history->array_[solution][step][0], projected_efields[solution]); + } +} + +void Integrator::BlochRHS::first_evaluation_of_timestep(const int step) const +{ + auto eval_and_sum = [step]( + const InteractionBase::ResultArray &r, + const std::shared_ptr &interaction) { + return r + interaction->first_evaluation_of_timestep(step); + }; + // TODO: change the evaluate function here to two seperate functions auto nil = InteractionBase::ResultArray::Zero(num_solutions, 1).eval(); auto projected_efields = std::accumulate( diff --git a/src/integrator/RHS/bloch_rhs.h b/src/integrator/RHS/bloch_rhs.h index fb82a9dd..642cc584 100644 --- a/src/integrator/RHS/bloch_rhs.h +++ b/src/integrator/RHS/bloch_rhs.h @@ -17,7 +17,8 @@ class Integrator::BlochRHS : public Integrator::RHS { const std::shared_ptr>, std::vector>, std::vector); - void evaluate(const int, const bool = true) const override; + void evaluate(const int) const override; + void first_evaluation_of_timestep(const int) const override; private: int num_solutions; diff --git a/src/integrator/RHS/ode_rhs.h b/src/integrator/RHS/ode_rhs.h index a5892368..d634f158 100644 --- a/src/integrator/RHS/ode_rhs.h +++ b/src/integrator/RHS/ode_rhs.h @@ -15,7 +15,8 @@ class Integrator::ODE_RHS : public RHS { ODE_RHS(const double, const std::shared_ptr>, const std::vector>); - void evaluate(const int, const bool) const; + void evaluate(const int) const; + void first_evaluation_of_timestep(const int) const; private: std::vector> rhs_functions; @@ -29,8 +30,7 @@ Integrator::ODE_RHS::ODE_RHS( { } -void Integrator::ODE_RHS::evaluate(const int n, - const bool first_call = true) const +void Integrator::ODE_RHS::evaluate(const int n) const { const double time = n * dt; for(int i = 0; i < static_cast(history->array_.shape()[0]); ++i) { @@ -38,4 +38,9 @@ void Integrator::ODE_RHS::evaluate(const int n, } } +void Integrator::ODE_RHS::first_evaluation_of_timestep(const int n) const +{ + evaluate(n); +} + #endif diff --git a/src/integrator/RHS/rhs.h b/src/integrator/RHS/rhs.h index 9d0b8b9f..d866c21e 100644 --- a/src/integrator/RHS/rhs.h +++ b/src/integrator/RHS/rhs.h @@ -14,7 +14,8 @@ class Integrator::RHS { public: RHS(const double dt, const std::shared_ptr> history) : dt(dt), history(std::move(history)){}; - virtual void evaluate(const int, const bool = true) const = 0; + virtual void evaluate(const int) const = 0; + virtual void first_evaluation_of_timestep(const int) const = 0; protected: double dt; diff --git a/src/integrator/integrator.h b/src/integrator/integrator.h index 53836ca6..9a374944 100644 --- a/src/integrator/integrator.h +++ b/src/integrator/integrator.h @@ -76,11 +76,11 @@ void Integrator::PredictorCorrector::solve_step(const int step) const assert(0 <= step && step < time_idx_ubound); predictor(step); - rhs->evaluate(step, true); + rhs->first_evaluation_of_timestep(step); for(int m = 0; m < num_corrector_steps; ++m) { corrector(step); - rhs->evaluate(step, false); + rhs->evaluate(step); } } diff --git a/src/interactions/AIM/aim_interaction.h b/src/interactions/AIM/aim_interaction.h index 6ef894bd..e7153b52 100644 --- a/src/interactions/AIM/aim_interaction.h +++ b/src/interactions/AIM/aim_interaction.h @@ -58,12 +58,19 @@ class AIM::Interaction final : public InteractionBase { { } - const ResultArray &evaluate(const int t, const bool first_call = true) + const ResultArray &first_evaluation_of_timestep(const int t) + { + results = (ff.first_evaluation_of_timestep(t).conjugate() - + nf.first_evaluation_of_timestep(t)) + + direct.first_evaluation_of_timestep(t); + return results; + } + + const ResultArray &evaluate(const int t) { // I DON'T KNOW WHY THAT NEEDS A CONJUGATE!!! results = - (ff.evaluate(t, first_call).conjugate() - nf.evaluate(t, first_call)) + - direct.evaluate(t, first_call); + (ff.evaluate(t).conjugate() - nf.evaluate(t)) + direct.evaluate(t); return results; } diff --git a/src/interactions/AIM/direct.cpp b/src/interactions/AIM/direct.cpp index f132e424..daf6149e 100644 --- a/src/interactions/AIM/direct.cpp +++ b/src/interactions/AIM/direct.cpp @@ -17,41 +17,99 @@ AIM::DirectInteraction::DirectInteraction( { } -const InteractionBase::ResultArray &AIM::DirectInteraction::evaluate( - const int time_idx, const bool first_call) +const InteractionBase::ResultArray & +AIM::DirectInteraction::first_evaluation_of_timestep(const int time_idx) { constexpr int RHO_01 = 1; - temp_res.setZero(); - if(first_call) results.setZero(); + results.setZero(); + past_terms_of_results.setZero(); for(int pair_idx = 0; pair_idx < shape_[0]; ++pair_idx) { const auto &pair = (*interaction_pairs_)[pair_idx]; - if(first_call) { - for(int i = 1; i < shape_[1]; ++i) { - const int s = - std::max(time_idx - floor_delays_[pair_idx] - i, - static_cast(history->array_.index_bases()[1])); - - results[pair.first] += (history->array_[pair.second][s][0])[RHO_01] * - coefficients_[pair_idx][i]; - results[pair.second] += (history->array_[pair.first][s][0])[RHO_01] * - coefficients_[pair_idx][i]; - } + for(int i = 1; i < shape_[1]; ++i) { + const int s = + std::max(time_idx - floor_delays_[pair_idx] - i, + static_cast(history->array_.index_bases()[1])); + + past_terms_of_results[pair.first] += + (history->array_[pair.second][s][0])[RHO_01] * + coefficients_[pair_idx][i]; + past_terms_of_results[pair.second] += + (history->array_[pair.first][s][0])[RHO_01] * + coefficients_[pair_idx][i]; } + + const int s = std::max(time_idx - floor_delays_[pair_idx], + static_cast(history->array_.index_bases()[1])); + + results[pair.first] += (history->array_[pair.second][s][0])[RHO_01] * + coefficients_[pair_idx][0]; + results[pair.second] += (history->array_[pair.first][s][0])[RHO_01] * + coefficients_[pair_idx][0]; + } + results += past_terms_of_results; + return results; +} + +const InteractionBase::ResultArray &AIM::DirectInteraction::evaluate( + const int time_idx) +{ + constexpr int RHO_01 = 1; + + results.setZero(); + + for(int pair_idx = 0; pair_idx < shape_[0]; ++pair_idx) { + const auto &pair = (*interaction_pairs_)[pair_idx]; + const int s = std::max(time_idx - floor_delays_[pair_idx], static_cast(history->array_.index_bases()[1])); - temp_res[pair.first] += (history->array_[pair.second][s][0])[RHO_01] * + results[pair.first] += (history->array_[pair.second][s][0])[RHO_01] * + coefficients_[pair_idx][0]; + results[pair.second] += (history->array_[pair.first][s][0])[RHO_01] * coefficients_[pair_idx][0]; - temp_res[pair.second] += (history->array_[pair.first][s][0])[RHO_01] * - coefficients_[pair_idx][0]; } - temp_res += results; - return temp_res; + results += past_terms_of_results; + return results; } +// const InteractionBase::ResultArray &AIM::DirectInteraction::evaluate( +// const int time_idx, const bool first_call) +// { +// constexpr int RHO_01 = 1; +// +// temp_res.setZero(); +// if(first_call) results.setZero(); +// +// for(int pair_idx = 0; pair_idx < shape_[0]; ++pair_idx) { +// const auto &pair = (*interaction_pairs_)[pair_idx]; +// +// if(first_call) { +// for(int i = 1; i < shape_[1]; ++i) { +// const int s = +// std::max(time_idx - floor_delays_[pair_idx] - i, +// static_cast(history->array_.index_bases()[1])); +// +// results[pair.first] += (history->array_[pair.second][s][0])[RHO_01] * +// coefficients_[pair_idx][i]; +// results[pair.second] += (history->array_[pair.first][s][0])[RHO_01] * +// coefficients_[pair_idx][i]; +// } +// } +// const int s = std::max(time_idx - floor_delays_[pair_idx], +// static_cast(history->array_.index_bases()[1])); +// +// temp_res[pair.first] += (history->array_[pair.second][s][0])[RHO_01] * +// coefficients_[pair_idx][0]; +// temp_res[pair.second] += (history->array_[pair.first][s][0])[RHO_01] * +// coefficients_[pair_idx][0]; +// } +// temp_res += results; +// return temp_res; +// } + boost::multi_array AIM::DirectInteraction::coefficient_table( Propagation::Kernel &kernel, std::vector &floor_delays) const { diff --git a/src/interactions/AIM/direct.h b/src/interactions/AIM/direct.h index 73486bad..46249306 100644 --- a/src/interactions/AIM/direct.h +++ b/src/interactions/AIM/direct.h @@ -18,7 +18,8 @@ class AIM::DirectInteraction final : public HistoryInteraction { const double, std::shared_ptr>); - const ResultArray &evaluate(const int, const bool = true) final; + const ResultArray &evaluate(const int) final; + const ResultArray &first_evaluation_of_timestep(const int) final; boost::multi_array coefficient_table(Propagation::Kernel &, std::vector &) const; diff --git a/src/interactions/AIM/farfield.cpp b/src/interactions/AIM/farfield.cpp index e7010706..89c8a1e9 100644 --- a/src/interactions/AIM/farfield.cpp +++ b/src/interactions/AIM/farfield.cpp @@ -63,7 +63,7 @@ void AIM::Farfield::fill_source_table(const int step) } } -void AIM::Farfield::propagate(const int step, const bool first_call) +void AIM::Farfield::first_propagate_of_timestep(const int step) { const auto wrapped_step = step % table_dimensions_[0]; const auto nb = 8 * grid->size(); @@ -77,21 +77,20 @@ void AIM::Farfield::propagate(const int step, const bool first_call) Eigen::Map observers(&obs_table_(front), 3, nb); observers = 0; // initialize temp_observers with the correct size and zero it - if(first_call) temp_observers = Eigen::Array3Xcd::Zero(3, nb); + temp_observers = Eigen::Array3Xcd::Zero(3, nb); - if(first_call) { - // compute convolution up to but not including the current timestep - for(int i = 1; i < table_dimensions_[0]; ++i) { - // If (step - i) runs "off the end", just propagate src[0][...] - auto wrap = std::max(step - i, 0) % table_dimensions_[0]; + // compute convolution up to but not including the current timestep + for(int i = 1; i < table_dimensions_[0]; ++i) { + // If (step - i) runs "off the end", just propagate src[0][...] + auto wrap = std::max(step - i, 0) % table_dimensions_[0]; - Eigen::Map prop(&propagation_table_[i][0][0][0], nb); - Eigen::Map src(&source_table_[wrap][0][0][0][0], 3, nb); + Eigen::Map prop(&propagation_table_[i][0][0][0], nb); + Eigen::Map src(&source_table_[wrap][0][0][0][0], 3, nb); - // Use broadcasting to do the x, y, and z component propagation - temp_observers += src.rowwise() * prop.transpose(); - } + // Use broadcasting to do the x, y, and z component propagation + temp_observers += src.rowwise() * prop.transpose(); } + // set observers equal to temp_observers // std::cout << temp_observers << "\n\n\n\n" << std::endl; observers += temp_observers; @@ -108,6 +107,80 @@ void AIM::Farfield::propagate(const int step, const bool first_call) reinterpret_cast(o_ptr)); } +void AIM::Farfield::propagate(const int step) +{ + const auto wrapped_step = step % table_dimensions_[0]; + const auto nb = 8 * grid->size(); + const std::array front = {{wrapped_step, 0, 0, 0, 0}}; + + const auto s_ptr = &source_table_(front); + fftw_execute_dft(spatial_vector_transforms_.forward, + reinterpret_cast(s_ptr), + reinterpret_cast(s_ptr)); + + Eigen::Map observers(&obs_table_(front), 3, nb); + observers = 0; + + observers += temp_observers; + + auto wrap = std::max(step, 0) % table_dimensions_[0]; // needed ? + + Eigen::Map prop(&propagation_table_[0][0][0][0], nb); + Eigen::Map src(&source_table_[wrap][0][0][0][0], 3, nb); + observers += src.rowwise() * prop.transpose(); + + const auto o_ptr = &obs_table_(front); + fftw_execute_dft(spatial_vector_transforms_.backward, + reinterpret_cast(o_ptr), + reinterpret_cast(o_ptr)); +} + +// void AIM::Farfield::propagate(const int step, const bool first_call) +// { +// const auto wrapped_step = step % table_dimensions_[0]; +// const auto nb = 8 * grid->size(); +// const std::array front = {{wrapped_step, 0, 0, 0, 0}}; +// +// const auto s_ptr = &source_table_(front); +// fftw_execute_dft(spatial_vector_transforms_.forward, +// reinterpret_cast(s_ptr), +// reinterpret_cast(s_ptr)); +// +// Eigen::Map observers(&obs_table_(front), 3, nb); +// observers = 0; +// // initialize temp_observers with the correct size and zero it +// if(first_call) temp_observers = Eigen::Array3Xcd::Zero(3, nb); +// +// if(first_call) { +// // compute convolution up to but not including the current timestep +// for(int i = 1; i < table_dimensions_[0]; ++i) { +// // If (step - i) runs "off the end", just propagate src[0][...] +// auto wrap = std::max(step - i, 0) % table_dimensions_[0]; +// +// Eigen::Map prop(&propagation_table_[i][0][0][0], nb); +// Eigen::Map src(&source_table_[wrap][0][0][0][0], 3, +// nb); +// +// // Use broadcasting to do the x, y, and z component propagation +// temp_observers += src.rowwise() * prop.transpose(); +// } +// } +// // set observers equal to temp_observers +// // std::cout << temp_observers << "\n\n\n\n" << std::endl; +// observers += temp_observers; +// +// auto wrap = std::max(step, 0) % table_dimensions_[0]; // needed ? +// +// Eigen::Map prop(&propagation_table_[0][0][0][0], nb); +// Eigen::Map src(&source_table_[wrap][0][0][0][0], 3, nb); +// observers += src.rowwise() * prop.transpose(); +// +// const auto o_ptr = &obs_table_(front); +// fftw_execute_dft(spatial_vector_transforms_.backward, +// reinterpret_cast(o_ptr), +// reinterpret_cast(o_ptr)); +// } + void AIM::Farfield::fill_results_table(const int step) { results = 0; diff --git a/src/interactions/AIM/farfield.h b/src/interactions/AIM/farfield.h index 90ab8378..0e6501c2 100644 --- a/src/interactions/AIM/farfield.h +++ b/src/interactions/AIM/farfield.h @@ -21,15 +21,21 @@ class AIM::Farfield final : public AimBase { Normalization::SpatialNorm); ~Farfield() = default; - const ResultArray &evaluate(const int step, - const bool first_call = true) final + const ResultArray &evaluate(const int step) final { fill_source_table(step); - propagate(step, first_call); + propagate(step); fill_results_table(step); return results; } + const ResultArray &first_evaluation_of_timestep(const int step) final + { + fill_source_table(step); + first_propagate_of_timestep(step); + fill_results_table(step); + return results; + } private: std::array table_dimensions_; @@ -46,7 +52,8 @@ class AIM::Farfield final : public AimBase { spacetime::vector make_propagation_table() const; void fill_source_table(const int); - void propagate(const int, const bool); + void propagate(const int); + void first_propagate_of_timestep(const int); void fill_results_table(const int); void fill_gmatrix_table(spacetime::vector &) const; diff --git a/src/interactions/AIM/nearfield.cpp b/src/interactions/AIM/nearfield.cpp index f77dfd18..dd508a63 100644 --- a/src/interactions/AIM/nearfield.cpp +++ b/src/interactions/AIM/nearfield.cpp @@ -28,50 +28,110 @@ AIM::Nearfield::Nearfield( support_(shape_[0], {std::numeric_limits::max(), 0}), coefficients_{coefficient_table()} { - if(interp_order != 5) - throw std::runtime_error( - "Lagrange interpolation of order != 5 is not supported in nearfield " - "calculations"); } -const InteractionBase::ResultArray &AIM::Nearfield::evaluate( - const int time_idx, const bool first_call) +const InteractionBase::ResultArray & +AIM::Nearfield::first_evaluation_of_timestep(const int time_idx) { constexpr int RH0_01 = 1; - temp_res.setZero(); - if(first_call) results.setZero(); + results.setZero(); + past_terms_of_results.setZero(); for(int pair_idx = 0; pair_idx < shape_[0]; ++pair_idx) { const auto &pair = (*interaction_pairs_)[pair_idx]; - if(first_call) { - for(int t = support_[pair_idx].begin + 1; t < support_[pair_idx].end; - ++t) { - const int s = std::max( - time_idx - t, static_cast(history->array_.index_bases()[1])); + for(int t = support_[pair_idx].begin + 1; t < support_[pair_idx].end; ++t) { + const int s = std::max( + time_idx - t, static_cast(history->array_.index_bases()[1])); - results[pair.first] += (history->array_[pair.second][s][0])[RHO_01] * - coefficients_[pair_idx][t][0]; - results[pair.second] += (history->array_[pair.first][s][0])[RHO_01] * - coefficients_[pair_idx][t][1]; - } + past_terms_of_results[pair.first] += + (history->array_[pair.second][s][0])[RHO_01] * + coefficients_[pair_idx][t][0]; + past_terms_of_results[pair.second] += + (history->array_[pair.first][s][0])[RHO_01] * + coefficients_[pair_idx][t][1]; } int t = support_[pair_idx].begin; const int s = std::max(time_idx - t, static_cast(history->array_.index_bases()[1])); assert(support_[pair_idx].begin == 0); - temp_res[pair.first] += (history->array_[pair.second][s][0])[RHO_01] * - coefficients_[pair_idx][t][0]; - temp_res[pair.second] += (history->array_[pair.first][s][0])[RHO_01] * - coefficients_[pair_idx][t][1]; + results[pair.first] += (history->array_[pair.second][s][0])[RHO_01] * + coefficients_[pair_idx][t][0]; + results[pair.second] += (history->array_[pair.first][s][0])[RHO_01] * + coefficients_[pair_idx][t][1]; + } + results += past_terms_of_results; + + return results; +} + +const InteractionBase::ResultArray &AIM::Nearfield::evaluate(const int time_idx) +{ + constexpr int RH0_01 = 1; + + results.setZero(); + + for(int pair_idx = 0; pair_idx < shape_[0]; ++pair_idx) { + const auto &pair = (*interaction_pairs_)[pair_idx]; + + int t = support_[pair_idx].begin; + const int s = std::max(time_idx - t, + static_cast(history->array_.index_bases()[1])); + assert(support_[pair_idx].begin == 0); + + results[pair.first] += (history->array_[pair.second][s][0])[RHO_01] * + coefficients_[pair_idx][t][0]; + results[pair.second] += (history->array_[pair.first][s][0])[RHO_01] * + coefficients_[pair_idx][t][1]; } - temp_res += results; + results += past_terms_of_results; - return temp_res; + return results; } +// const InteractionBase::ResultArray &AIM::Nearfield::evaluate( +// const int time_idx, const bool first_call) +// { +// constexpr int RH0_01 = 1; +// +// results.setZero(); +// if(first_call) past_terms_of_results.setZero(); +// +// for(int pair_idx = 0; pair_idx < shape_[0]; ++pair_idx) { +// const auto &pair = (*interaction_pairs_)[pair_idx]; +// +// if(first_call) { +// for(int t = support_[pair_idx].begin + 1; t < support_[pair_idx].end; +// ++t) { +// const int s = std::max( +// time_idx - t, +// static_cast(history->array_.index_bases()[1])); +// +// past_terms_of_results[pair.first] += +// (history->array_[pair.second][s][0])[RHO_01] * +// coefficients_[pair_idx][t][0]; +// past_terms_of_results[pair.second] += +// (history->array_[pair.first][s][0])[RHO_01] * +// coefficients_[pair_idx][t][1]; +// } +// } +// int t = support_[pair_idx].begin; +// const int s = std::max(time_idx - t, +// static_cast(history->array_.index_bases()[1])); +// assert(support_[pair_idx].begin == 0); +// +// results[pair.first] += (history->array_[pair.second][s][0])[RHO_01] * +// coefficients_[pair_idx][t][0]; +// results[pair.second] += (history->array_[pair.first][s][0])[RHO_01] * +// coefficients_[pair_idx][t][1]; +// } +// results += past_terms_of_results; +// +// return results; +// } + boost::multi_array AIM::Nearfield::coefficient_table() { boost::multi_array coefficients(shape_); diff --git a/src/interactions/AIM/nearfield.h b/src/interactions/AIM/nearfield.h index 02ce3023..40ffe959 100644 --- a/src/interactions/AIM/nearfield.h +++ b/src/interactions/AIM/nearfield.h @@ -23,7 +23,8 @@ class AIM::Nearfield final : public AimBase { const double = 0); ~Nearfield() = default; - const ResultArray &evaluate(const int, const bool = true) final; + const ResultArray &evaluate(const int) final; + const ResultArray &first_evaluation_of_timestep(const int) final; private: struct support_range_t { diff --git a/src/interactions/direct_interaction.cpp b/src/interactions/direct_interaction.cpp index 1c0ae79d..5faa2e85 100644 --- a/src/interactions/direct_interaction.cpp +++ b/src/interactions/direct_interaction.cpp @@ -42,42 +42,100 @@ void DirectInteraction::build_coefficient_table( } } -const InteractionBase::ResultArray &DirectInteraction::evaluate( - const int time_idx, const bool first_call) +const InteractionBase::ResultArray & +DirectInteraction::first_evaluation_of_timestep(const int time_idx) { constexpr int RHO_01 = 1; - temp_res.setZero(); - if(first_call) results.setZero(); + results.setZero(); + past_terms_of_results.setZero(); // iterate through all dot pairs for(int pair_idx = 0; pair_idx < num_interactions; ++pair_idx) { int src, obs; std::tie(src, obs) = idx2coord(pair_idx); - if(first_call) { // sum over history if this is the first call - for(int i = 1; i <= interp_order; ++i) { - const int s = - std::max(time_idx - floor_delays[pair_idx] - i, - static_cast(history->array_.index_bases()[1])); - - results[src] += - (history->array_[obs][s][0])[RHO_01] * coefficients[pair_idx][i]; - results[obs] += - (history->array_[src][s][0])[RHO_01] * coefficients[pair_idx][i]; - } + for(int i = 1; i <= interp_order; ++i) { + const int s = + std::max(time_idx - floor_delays[pair_idx] - i, + static_cast(history->array_.index_bases()[1])); + + past_terms_of_results[src] += + (history->array_[obs][s][0])[RHO_01] * coefficients[pair_idx][i]; + past_terms_of_results[obs] += + (history->array_[src][s][0])[RHO_01] * coefficients[pair_idx][i]; } + // TODO: just call evaluate here? + const int s = std::max(time_idx - floor_delays[pair_idx], + static_cast(history->array_.index_bases()[1])); + + results[src] += + (history->array_[obs][s][0])[RHO_01] * coefficients[pair_idx][0]; + results[obs] += + (history->array_[src][s][0])[RHO_01] * coefficients[pair_idx][0]; + } + results += past_terms_of_results; + return results; +} + +const InteractionBase::ResultArray &DirectInteraction::evaluate( + const int time_idx) +{ + constexpr int RHO_01 = 1; + results.setZero(); + + // iterate through all dot pairs + for(int pair_idx = 0; pair_idx < num_interactions; ++pair_idx) { + int src, obs; + std::tie(src, obs) = idx2coord(pair_idx); + const int s = std::max(time_idx - floor_delays[pair_idx], static_cast(history->array_.index_bases()[1])); - temp_res[src] += + results[src] += (history->array_[obs][s][0])[RHO_01] * coefficients[pair_idx][0]; - temp_res[obs] += + results[obs] += (history->array_[src][s][0])[RHO_01] * coefficients[pair_idx][0]; } - temp_res += results; - return temp_res; + results += past_terms_of_results; + return results; } +// const InteractionBase::ResultArray &DirectInteraction::evaluate( +// const int time_idx, const bool first_call) +// { +// constexpr int RHO_01 = 1; +// temp_res.setZero(); +// if(first_call) results.setZero(); +// +// // iterate through all dot pairs +// for(int pair_idx = 0; pair_idx < num_interactions; ++pair_idx) { +// int src, obs; +// std::tie(src, obs) = idx2coord(pair_idx); +// +// if(first_call) { // sum over history if this is the first call +// for(int i = 1; i <= interp_order; ++i) { +// const int s = +// std::max(time_idx - floor_delays[pair_idx] - i, +// static_cast(history->array_.index_bases()[1])); +// +// results[src] += +// (history->array_[obs][s][0])[RHO_01] * coefficients[pair_idx][i]; +// results[obs] += +// (history->array_[src][s][0])[RHO_01] * coefficients[pair_idx][i]; +// } +// } +// const int s = std::max(time_idx - floor_delays[pair_idx], +// static_cast(history->array_.index_bases()[1])); +// +// temp_res[src] += +// (history->array_[obs][s][0])[RHO_01] * coefficients[pair_idx][0]; +// temp_res[obs] += +// (history->array_[src][s][0])[RHO_01] * coefficients[pair_idx][0]; +// } +// temp_res += results; +// return temp_res; +// } + int DirectInteraction::coord2idx(int row, int col) { assert(row != col); diff --git a/src/interactions/direct_interaction.h b/src/interactions/direct_interaction.h index 4d1f7a0e..909f061b 100644 --- a/src/interactions/direct_interaction.h +++ b/src/interactions/direct_interaction.h @@ -13,7 +13,8 @@ class DirectInteraction final : public HistoryInteraction { const double, const double); - const ResultArray &evaluate(const int, const bool = true) final; + const ResultArray &evaluate(const int) final; + const ResultArray &first_evaluation_of_timestep(const int) final; private: int num_interactions; diff --git a/src/interactions/interaction.h b/src/interactions/interaction.h index ac029ebe..35ed2d48 100644 --- a/src/interactions/interaction.h +++ b/src/interactions/interaction.h @@ -13,16 +13,18 @@ class InteractionBase { InteractionBase(const std::shared_ptr dots, const double dt) : dots(std::move(dots)), results(dots ? dots->size() : 0), - temp_res(dots ? dots->size() : 0), + past_terms_of_results(dots ? dots->size() : 0), dt(dt){}; // const cmplx &operator[](const int i) const { return results[i]; } - virtual const ResultArray &evaluate(const int, const bool = true) = 0; + virtual const ResultArray &evaluate(const int) = 0; + virtual const ResultArray &first_evaluation_of_timestep(const int) = 0; + virtual ~InteractionBase(){}; protected: std::shared_ptr dots; ResultArray results; - ResultArray temp_res; + ResultArray past_terms_of_results; double dt; }; diff --git a/src/interactions/pulse_interaction.cpp b/src/interactions/pulse_interaction.cpp index 3cc1fabc..7ba801c6 100644 --- a/src/interactions/pulse_interaction.cpp +++ b/src/interactions/pulse_interaction.cpp @@ -9,7 +9,7 @@ PulseInteraction::PulseInteraction(const std::shared_ptr dots, } const InteractionBase::ResultArray &PulseInteraction::evaluate( - const int time_idx, const bool first_call) + const int time_idx) { const double time = time_idx * dt; diff --git a/src/interactions/pulse_interaction.h b/src/interactions/pulse_interaction.h index 3b3b33ee..5111c156 100644 --- a/src/interactions/pulse_interaction.h +++ b/src/interactions/pulse_interaction.h @@ -10,7 +10,11 @@ class PulseInteraction : public InteractionBase { const std::shared_ptr, const double, const double); - virtual const ResultArray &evaluate(const int, const bool = true); + virtual const ResultArray &evaluate(const int); + virtual const ResultArray &first_evaluation_of_timestep(const int n) + { + return evaluate(n); + } private: std::shared_ptr pulse; diff --git a/test/propagator_test.cpp b/test/propagator_test.cpp index 1be31536..1b66973a 100644 --- a/test/propagator_test.cpp +++ b/test/propagator_test.cpp @@ -73,7 +73,8 @@ BOOST_FIXTURE_TEST_CASE(DIRECT_INTERACTION, SimulationStructures) for(int i = 0; i < num_timesteps; ++i) { BOOST_TEST_MESSAGE(i); - const double obs_val_calculated = direct_interaction.evaluate(i)(1).real(); + const double obs_val_calculated = + direct_interaction.first_evaluation_of_timestep(i)(1).real(); const double obs_val_actual = obs_fn(i * dt); BOOST_REQUIRE_CLOSE_FRACTION(obs_val_calculated, obs_val_actual, 1e-9); } @@ -98,7 +99,8 @@ BOOST_FIXTURE_TEST_CASE(AIM_INTERACTION, SimulationStructures) for(int i = 0; i < num_timesteps; ++i) { BOOST_TEST_MESSAGE(i); - const double obs_val_calculated = aim_interaction.evaluate(i)(1).real(); + const double obs_val_calculated = + aim_interaction.first_evaluation_of_timestep(i)(1).real(); const double obs_val_actual = obs_fn(i * dt); if(i > 16) { @@ -116,4 +118,4 @@ BOOST_FIXTURE_TEST_CASE(AIM_INTERACTION, SimulationStructures) BOOST_AUTO_TEST_SUITE_END() // RETARDED_GAUSSIAN -BOOST_AUTO_TEST_SUITE_END() // PROPAGATION \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() // PROPAGATION From ca8168cae6fdf42280e90d05d01a387ee75e4802 Mon Sep 17 00:00:00 2001 From: Thomas Bertus Date: Mon, 1 Jun 2020 19:56:39 -0400 Subject: [PATCH 35/43] reintroducing some unit tests --- test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0919286a..05723db9 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -12,7 +12,7 @@ if(${Boost_FOUND}) PUBLIC "${CMAKE_CURRENT_LIST_DIR}/integrator_test.cpp" "${CMAKE_CURRENT_LIST_DIR}/lagrange_set_test.cpp" - # "${CMAKE_CURRENT_LIST_DIR}/math_utils_test.cpp" + "${CMAKE_CURRENT_LIST_DIR}/math_utils_test.cpp" "${CMAKE_CURRENT_LIST_DIR}/propagator_test.cpp" "${CMAKE_CURRENT_LIST_DIR}/pulse_interaction_test.cpp" "${CMAKE_CURRENT_LIST_DIR}/quantum_dot_test.cpp" From 42948a64fea1ba51a588b23a9427b9277b6b7128 Mon Sep 17 00:00:00 2001 From: Thomas Bertus Date: Mon, 1 Jun 2020 20:06:22 -0400 Subject: [PATCH 36/43] including unit test --- test/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 05723db9..2f45584b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -18,8 +18,8 @@ if(${Boost_FOUND}) "${CMAKE_CURRENT_LIST_DIR}/quantum_dot_test.cpp" ) - # add_subdirectory("extras/rapidcheck") - # add_subdirectory("extras/rapidcheck/extras/boost_test") + add_subdirectory("extras/rapidcheck") + add_subdirectory("extras/rapidcheck/extras/boost_test") - target_link_libraries(qtest-bin PUBLIC quest ${Boost_LIBRARIES})# rapidcheck rapidcheck_boost_test) + target_link_libraries(qtest-bin PUBLIC quest ${Boost_LIBRARIES} rapidcheck rapidcheck_boost_test) endif(${Boost_FOUND}) From e74e86d212ee5418b873c2cacc4b00bb7aa0d6d3 Mon Sep 17 00:00:00 2001 From: Thomas Bertus Date: Mon, 1 Jun 2020 20:14:21 -0400 Subject: [PATCH 37/43] corrected submodule location --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 4fc2013e..ce7798f2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "rapidcheck"] +[submodule "extras/rapidcheck"] path = rapidcheck url = https://github.com/emil-e/rapidcheck.git From 66cc336dd1de5c116abee1afd441c770b06cf25c Mon Sep 17 00:00:00 2001 From: Thomas Bertus Date: Mon, 1 Jun 2020 20:23:52 -0400 Subject: [PATCH 38/43] trying to get travis CI to work --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index c2a812d1..1601bc43 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ compiler: before_script: - sudo ./install/get_boost.sh > /dev/null - sudo ./install/get_eigen.sh > /dev/null + - ls extras/rapidcheck/ - mkdir build && cd build - cmake .. From 3bf248cd728d72c45687caa9b8a2074798e347d7 Mon Sep 17 00:00:00 2001 From: Thomas Bertus Date: Mon, 1 Jun 2020 20:41:06 -0400 Subject: [PATCH 39/43] trying to get rapidcheck to work with travis on this branch --- .gitmodules | 2 +- .travis.yml | 1 - test/CMakeLists.txt | 4 ++-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.gitmodules b/.gitmodules index ce7798f2..4fc2013e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "extras/rapidcheck"] +[submodule "rapidcheck"] path = rapidcheck url = https://github.com/emil-e/rapidcheck.git diff --git a/.travis.yml b/.travis.yml index 1601bc43..c2a812d1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,6 @@ compiler: before_script: - sudo ./install/get_boost.sh > /dev/null - sudo ./install/get_eigen.sh > /dev/null - - ls extras/rapidcheck/ - mkdir build && cd build - cmake .. diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 2f45584b..145f4eff 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -18,8 +18,8 @@ if(${Boost_FOUND}) "${CMAKE_CURRENT_LIST_DIR}/quantum_dot_test.cpp" ) - add_subdirectory("extras/rapidcheck") - add_subdirectory("extras/rapidcheck/extras/boost_test") + add_subdirectory("rapidcheck") + add_subdirectory("rapidcheck/extras/boost_test") target_link_libraries(qtest-bin PUBLIC quest ${Boost_LIBRARIES} rapidcheck rapidcheck_boost_test) endif(${Boost_FOUND}) From 54c8771db084e9baddea1015ad7ce80a816141ce Mon Sep 17 00:00:00 2001 From: Thomas Bertus Date: Mon, 1 Jun 2020 22:27:58 -0400 Subject: [PATCH 40/43] removed unneeded comments --- src/integrator/RHS/bloch_rhs.cpp | 2 -- src/interactions/direct_interaction.cpp | 1 - 2 files changed, 3 deletions(-) diff --git a/src/integrator/RHS/bloch_rhs.cpp b/src/integrator/RHS/bloch_rhs.cpp index 0621195c..2b620d61 100644 --- a/src/integrator/RHS/bloch_rhs.cpp +++ b/src/integrator/RHS/bloch_rhs.cpp @@ -19,7 +19,6 @@ void Integrator::BlochRHS::evaluate(const int step) const const std::shared_ptr &interaction) { return r + interaction->evaluate(step); }; - // TODO: change the evaluate function here to two seperate functions auto nil = InteractionBase::ResultArray::Zero(num_solutions, 1).eval(); auto projected_efields = std::accumulate( @@ -38,7 +37,6 @@ void Integrator::BlochRHS::first_evaluation_of_timestep(const int step) const const std::shared_ptr &interaction) { return r + interaction->first_evaluation_of_timestep(step); }; - // TODO: change the evaluate function here to two seperate functions auto nil = InteractionBase::ResultArray::Zero(num_solutions, 1).eval(); auto projected_efields = std::accumulate( diff --git a/src/interactions/direct_interaction.cpp b/src/interactions/direct_interaction.cpp index 5faa2e85..afbfa579 100644 --- a/src/interactions/direct_interaction.cpp +++ b/src/interactions/direct_interaction.cpp @@ -64,7 +64,6 @@ DirectInteraction::first_evaluation_of_timestep(const int time_idx) past_terms_of_results[obs] += (history->array_[src][s][0])[RHO_01] * coefficients[pair_idx][i]; } - // TODO: just call evaluate here? const int s = std::max(time_idx - floor_delays[pair_idx], static_cast(history->array_.index_bases()[1])); From 47bbd6530a484be1aee64a0fa2dc208ec682b2c8 Mon Sep 17 00:00:00 2001 From: Thomas Bertus Date: Tue, 2 Jun 2020 11:11:44 -0400 Subject: [PATCH 41/43] remove old code --- src/interactions/AIM/direct.cpp | 35 ------------------- src/interactions/AIM/farfield.cpp | 46 ------------------------- src/interactions/AIM/nearfield.cpp | 41 ---------------------- src/interactions/direct_interaction.cpp | 36 ------------------- 4 files changed, 158 deletions(-) diff --git a/src/interactions/AIM/direct.cpp b/src/interactions/AIM/direct.cpp index daf6149e..f8df7875 100644 --- a/src/interactions/AIM/direct.cpp +++ b/src/interactions/AIM/direct.cpp @@ -75,41 +75,6 @@ const InteractionBase::ResultArray &AIM::DirectInteraction::evaluate( return results; } -// const InteractionBase::ResultArray &AIM::DirectInteraction::evaluate( -// const int time_idx, const bool first_call) -// { -// constexpr int RHO_01 = 1; -// -// temp_res.setZero(); -// if(first_call) results.setZero(); -// -// for(int pair_idx = 0; pair_idx < shape_[0]; ++pair_idx) { -// const auto &pair = (*interaction_pairs_)[pair_idx]; -// -// if(first_call) { -// for(int i = 1; i < shape_[1]; ++i) { -// const int s = -// std::max(time_idx - floor_delays_[pair_idx] - i, -// static_cast(history->array_.index_bases()[1])); -// -// results[pair.first] += (history->array_[pair.second][s][0])[RHO_01] * -// coefficients_[pair_idx][i]; -// results[pair.second] += (history->array_[pair.first][s][0])[RHO_01] * -// coefficients_[pair_idx][i]; -// } -// } -// const int s = std::max(time_idx - floor_delays_[pair_idx], -// static_cast(history->array_.index_bases()[1])); -// -// temp_res[pair.first] += (history->array_[pair.second][s][0])[RHO_01] * -// coefficients_[pair_idx][0]; -// temp_res[pair.second] += (history->array_[pair.first][s][0])[RHO_01] * -// coefficients_[pair_idx][0]; -// } -// temp_res += results; -// return temp_res; -// } - boost::multi_array AIM::DirectInteraction::coefficient_table( Propagation::Kernel &kernel, std::vector &floor_delays) const { diff --git a/src/interactions/AIM/farfield.cpp b/src/interactions/AIM/farfield.cpp index 89c8a1e9..b9c694ae 100644 --- a/src/interactions/AIM/farfield.cpp +++ b/src/interactions/AIM/farfield.cpp @@ -135,52 +135,6 @@ void AIM::Farfield::propagate(const int step) reinterpret_cast(o_ptr)); } -// void AIM::Farfield::propagate(const int step, const bool first_call) -// { -// const auto wrapped_step = step % table_dimensions_[0]; -// const auto nb = 8 * grid->size(); -// const std::array front = {{wrapped_step, 0, 0, 0, 0}}; -// -// const auto s_ptr = &source_table_(front); -// fftw_execute_dft(spatial_vector_transforms_.forward, -// reinterpret_cast(s_ptr), -// reinterpret_cast(s_ptr)); -// -// Eigen::Map observers(&obs_table_(front), 3, nb); -// observers = 0; -// // initialize temp_observers with the correct size and zero it -// if(first_call) temp_observers = Eigen::Array3Xcd::Zero(3, nb); -// -// if(first_call) { -// // compute convolution up to but not including the current timestep -// for(int i = 1; i < table_dimensions_[0]; ++i) { -// // If (step - i) runs "off the end", just propagate src[0][...] -// auto wrap = std::max(step - i, 0) % table_dimensions_[0]; -// -// Eigen::Map prop(&propagation_table_[i][0][0][0], nb); -// Eigen::Map src(&source_table_[wrap][0][0][0][0], 3, -// nb); -// -// // Use broadcasting to do the x, y, and z component propagation -// temp_observers += src.rowwise() * prop.transpose(); -// } -// } -// // set observers equal to temp_observers -// // std::cout << temp_observers << "\n\n\n\n" << std::endl; -// observers += temp_observers; -// -// auto wrap = std::max(step, 0) % table_dimensions_[0]; // needed ? -// -// Eigen::Map prop(&propagation_table_[0][0][0][0], nb); -// Eigen::Map src(&source_table_[wrap][0][0][0][0], 3, nb); -// observers += src.rowwise() * prop.transpose(); -// -// const auto o_ptr = &obs_table_(front); -// fftw_execute_dft(spatial_vector_transforms_.backward, -// reinterpret_cast(o_ptr), -// reinterpret_cast(o_ptr)); -// } - void AIM::Farfield::fill_results_table(const int step) { results = 0; diff --git a/src/interactions/AIM/nearfield.cpp b/src/interactions/AIM/nearfield.cpp index dd508a63..07495e63 100644 --- a/src/interactions/AIM/nearfield.cpp +++ b/src/interactions/AIM/nearfield.cpp @@ -91,47 +91,6 @@ const InteractionBase::ResultArray &AIM::Nearfield::evaluate(const int time_idx) return results; } -// const InteractionBase::ResultArray &AIM::Nearfield::evaluate( -// const int time_idx, const bool first_call) -// { -// constexpr int RH0_01 = 1; -// -// results.setZero(); -// if(first_call) past_terms_of_results.setZero(); -// -// for(int pair_idx = 0; pair_idx < shape_[0]; ++pair_idx) { -// const auto &pair = (*interaction_pairs_)[pair_idx]; -// -// if(first_call) { -// for(int t = support_[pair_idx].begin + 1; t < support_[pair_idx].end; -// ++t) { -// const int s = std::max( -// time_idx - t, -// static_cast(history->array_.index_bases()[1])); -// -// past_terms_of_results[pair.first] += -// (history->array_[pair.second][s][0])[RHO_01] * -// coefficients_[pair_idx][t][0]; -// past_terms_of_results[pair.second] += -// (history->array_[pair.first][s][0])[RHO_01] * -// coefficients_[pair_idx][t][1]; -// } -// } -// int t = support_[pair_idx].begin; -// const int s = std::max(time_idx - t, -// static_cast(history->array_.index_bases()[1])); -// assert(support_[pair_idx].begin == 0); -// -// results[pair.first] += (history->array_[pair.second][s][0])[RHO_01] * -// coefficients_[pair_idx][t][0]; -// results[pair.second] += (history->array_[pair.first][s][0])[RHO_01] * -// coefficients_[pair_idx][t][1]; -// } -// results += past_terms_of_results; -// -// return results; -// } - boost::multi_array AIM::Nearfield::coefficient_table() { boost::multi_array coefficients(shape_); diff --git a/src/interactions/direct_interaction.cpp b/src/interactions/direct_interaction.cpp index afbfa579..aa51e90a 100644 --- a/src/interactions/direct_interaction.cpp +++ b/src/interactions/direct_interaction.cpp @@ -99,42 +99,6 @@ const InteractionBase::ResultArray &DirectInteraction::evaluate( return results; } -// const InteractionBase::ResultArray &DirectInteraction::evaluate( -// const int time_idx, const bool first_call) -// { -// constexpr int RHO_01 = 1; -// temp_res.setZero(); -// if(first_call) results.setZero(); -// -// // iterate through all dot pairs -// for(int pair_idx = 0; pair_idx < num_interactions; ++pair_idx) { -// int src, obs; -// std::tie(src, obs) = idx2coord(pair_idx); -// -// if(first_call) { // sum over history if this is the first call -// for(int i = 1; i <= interp_order; ++i) { -// const int s = -// std::max(time_idx - floor_delays[pair_idx] - i, -// static_cast(history->array_.index_bases()[1])); -// -// results[src] += -// (history->array_[obs][s][0])[RHO_01] * coefficients[pair_idx][i]; -// results[obs] += -// (history->array_[src][s][0])[RHO_01] * coefficients[pair_idx][i]; -// } -// } -// const int s = std::max(time_idx - floor_delays[pair_idx], -// static_cast(history->array_.index_bases()[1])); -// -// temp_res[src] += -// (history->array_[obs][s][0])[RHO_01] * coefficients[pair_idx][0]; -// temp_res[obs] += -// (history->array_[src][s][0])[RHO_01] * coefficients[pair_idx][0]; -// } -// temp_res += results; -// return temp_res; -// } - int DirectInteraction::coord2idx(int row, int col) { assert(row != col); From 6b9308a077085a4a1b21f512ceccb03dcc06925c Mon Sep 17 00:00:00 2001 From: Thomas Bertus Date: Wed, 10 Jun 2020 23:12:19 -0400 Subject: [PATCH 42/43] renamed evaluate functions of rhs and interaction classes --- src/integrator/RHS/bloch_rhs.cpp | 8 ++++---- src/integrator/RHS/bloch_rhs.h | 2 +- src/integrator/RHS/ode_rhs.h | 7 ++----- src/integrator/RHS/rhs.h | 2 +- src/integrator/integrator.h | 4 ++-- src/interactions/AIM/aim_interaction.h | 14 +++++++------- src/interactions/AIM/direct.cpp | 8 ++++---- src/interactions/AIM/direct.h | 2 +- src/interactions/AIM/farfield.cpp | 4 ++-- src/interactions/AIM/farfield.h | 10 +++++----- src/interactions/AIM/nearfield.cpp | 6 +++--- src/interactions/AIM/nearfield.h | 2 +- src/interactions/direct_interaction.cpp | 6 +++--- src/interactions/direct_interaction.h | 2 +- src/interactions/interaction.h | 2 +- src/interactions/pulse_interaction.h | 2 +- test/propagator_test.cpp | 6 ++---- 17 files changed, 41 insertions(+), 46 deletions(-) diff --git a/src/integrator/RHS/bloch_rhs.cpp b/src/integrator/RHS/bloch_rhs.cpp index 2b620d61..73a2fece 100644 --- a/src/integrator/RHS/bloch_rhs.cpp +++ b/src/integrator/RHS/bloch_rhs.cpp @@ -12,12 +12,12 @@ Integrator::BlochRHS::BlochRHS( { } -void Integrator::BlochRHS::evaluate(const int step) const +void Integrator::BlochRHS::evaluate_present(const int step) const { auto eval_and_sum = [step]( const InteractionBase::ResultArray &r, const std::shared_ptr &interaction) { - return r + interaction->evaluate(step); + return r + interaction->evaluate_present_field(step); }; auto nil = InteractionBase::ResultArray::Zero(num_solutions, 1).eval(); @@ -30,12 +30,12 @@ void Integrator::BlochRHS::evaluate(const int step) const } } -void Integrator::BlochRHS::first_evaluation_of_timestep(const int step) const +void Integrator::BlochRHS::evaluate(const int step) const { auto eval_and_sum = [step]( const InteractionBase::ResultArray &r, const std::shared_ptr &interaction) { - return r + interaction->first_evaluation_of_timestep(step); + return r + interaction->evaluate(step); }; auto nil = InteractionBase::ResultArray::Zero(num_solutions, 1).eval(); diff --git a/src/integrator/RHS/bloch_rhs.h b/src/integrator/RHS/bloch_rhs.h index 642cc584..aade6842 100644 --- a/src/integrator/RHS/bloch_rhs.h +++ b/src/integrator/RHS/bloch_rhs.h @@ -17,8 +17,8 @@ class Integrator::BlochRHS : public Integrator::RHS { const std::shared_ptr>, std::vector>, std::vector); + void evaluate_present(const int) const override; void evaluate(const int) const override; - void first_evaluation_of_timestep(const int) const override; private: int num_solutions; diff --git a/src/integrator/RHS/ode_rhs.h b/src/integrator/RHS/ode_rhs.h index d634f158..d374e636 100644 --- a/src/integrator/RHS/ode_rhs.h +++ b/src/integrator/RHS/ode_rhs.h @@ -15,8 +15,8 @@ class Integrator::ODE_RHS : public RHS { ODE_RHS(const double, const std::shared_ptr>, const std::vector>); + void evaluate_present(const int) const; void evaluate(const int) const; - void first_evaluation_of_timestep(const int) const; private: std::vector> rhs_functions; @@ -38,9 +38,6 @@ void Integrator::ODE_RHS::evaluate(const int n) const } } -void Integrator::ODE_RHS::first_evaluation_of_timestep(const int n) const -{ - evaluate(n); -} +void Integrator::ODE_RHS::evaluate_present(const int n) const { evaluate(n); } #endif diff --git a/src/integrator/RHS/rhs.h b/src/integrator/RHS/rhs.h index d866c21e..d231b602 100644 --- a/src/integrator/RHS/rhs.h +++ b/src/integrator/RHS/rhs.h @@ -14,8 +14,8 @@ class Integrator::RHS { public: RHS(const double dt, const std::shared_ptr> history) : dt(dt), history(std::move(history)){}; + virtual void evaluate_present(const int) const = 0; virtual void evaluate(const int) const = 0; - virtual void first_evaluation_of_timestep(const int) const = 0; protected: double dt; diff --git a/src/integrator/integrator.h b/src/integrator/integrator.h index 9a374944..6f703d36 100644 --- a/src/integrator/integrator.h +++ b/src/integrator/integrator.h @@ -76,11 +76,11 @@ void Integrator::PredictorCorrector::solve_step(const int step) const assert(0 <= step && step < time_idx_ubound); predictor(step); - rhs->first_evaluation_of_timestep(step); + rhs->evaluate(step); for(int m = 0; m < num_corrector_steps; ++m) { corrector(step); - rhs->evaluate(step); + rhs->evaluate_present(step); } } diff --git a/src/interactions/AIM/aim_interaction.h b/src/interactions/AIM/aim_interaction.h index e7153b52..14d01ff0 100644 --- a/src/interactions/AIM/aim_interaction.h +++ b/src/interactions/AIM/aim_interaction.h @@ -58,19 +58,19 @@ class AIM::Interaction final : public InteractionBase { { } - const ResultArray &first_evaluation_of_timestep(const int t) + const ResultArray &evaluate(const int t) { - results = (ff.first_evaluation_of_timestep(t).conjugate() - - nf.first_evaluation_of_timestep(t)) + - direct.first_evaluation_of_timestep(t); + results = + (ff.evaluate(t).conjugate() - nf.evaluate(t)) + direct.evaluate(t); return results; } - const ResultArray &evaluate(const int t) + const ResultArray &evaluate_present_field(const int t) { // I DON'T KNOW WHY THAT NEEDS A CONJUGATE!!! - results = - (ff.evaluate(t).conjugate() - nf.evaluate(t)) + direct.evaluate(t); + results = (ff.evaluate_present_field(t).conjugate() - + nf.evaluate_present_field(t)) + + direct.evaluate_present_field(t); return results; } diff --git a/src/interactions/AIM/direct.cpp b/src/interactions/AIM/direct.cpp index f8df7875..4dc77a42 100644 --- a/src/interactions/AIM/direct.cpp +++ b/src/interactions/AIM/direct.cpp @@ -17,8 +17,8 @@ AIM::DirectInteraction::DirectInteraction( { } -const InteractionBase::ResultArray & -AIM::DirectInteraction::first_evaluation_of_timestep(const int time_idx) +const InteractionBase::ResultArray &AIM::DirectInteraction::evaluate( + const int time_idx) { constexpr int RHO_01 = 1; @@ -53,8 +53,8 @@ AIM::DirectInteraction::first_evaluation_of_timestep(const int time_idx) return results; } -const InteractionBase::ResultArray &AIM::DirectInteraction::evaluate( - const int time_idx) +const InteractionBase::ResultArray & +AIM::DirectInteraction::evaluate_present_field(const int time_idx) { constexpr int RHO_01 = 1; diff --git a/src/interactions/AIM/direct.h b/src/interactions/AIM/direct.h index 46249306..5dfe9ba1 100644 --- a/src/interactions/AIM/direct.h +++ b/src/interactions/AIM/direct.h @@ -19,7 +19,7 @@ class AIM::DirectInteraction final : public HistoryInteraction { std::shared_ptr>); const ResultArray &evaluate(const int) final; - const ResultArray &first_evaluation_of_timestep(const int) final; + const ResultArray &evaluate_present_field(const int) final; boost::multi_array coefficient_table(Propagation::Kernel &, std::vector &) const; diff --git a/src/interactions/AIM/farfield.cpp b/src/interactions/AIM/farfield.cpp index b9c694ae..1d59ddf4 100644 --- a/src/interactions/AIM/farfield.cpp +++ b/src/interactions/AIM/farfield.cpp @@ -63,7 +63,7 @@ void AIM::Farfield::fill_source_table(const int step) } } -void AIM::Farfield::first_propagate_of_timestep(const int step) +void AIM::Farfield::propagate(const int step) { const auto wrapped_step = step % table_dimensions_[0]; const auto nb = 8 * grid->size(); @@ -107,7 +107,7 @@ void AIM::Farfield::first_propagate_of_timestep(const int step) reinterpret_cast(o_ptr)); } -void AIM::Farfield::propagate(const int step) +void AIM::Farfield::propagate_present_field(const int step) { const auto wrapped_step = step % table_dimensions_[0]; const auto nb = 8 * grid->size(); diff --git a/src/interactions/AIM/farfield.h b/src/interactions/AIM/farfield.h index 0e6501c2..a4890cc9 100644 --- a/src/interactions/AIM/farfield.h +++ b/src/interactions/AIM/farfield.h @@ -21,18 +21,18 @@ class AIM::Farfield final : public AimBase { Normalization::SpatialNorm); ~Farfield() = default; - const ResultArray &evaluate(const int step) final + const ResultArray &evaluate_present_field(const int step) final { fill_source_table(step); - propagate(step); + propagate_present_field(step); fill_results_table(step); return results; } - const ResultArray &first_evaluation_of_timestep(const int step) final + const ResultArray &evaluate(const int step) final { fill_source_table(step); - first_propagate_of_timestep(step); + propagate(step); fill_results_table(step); return results; } @@ -53,7 +53,7 @@ class AIM::Farfield final : public AimBase { spacetime::vector make_propagation_table() const; void fill_source_table(const int); void propagate(const int); - void first_propagate_of_timestep(const int); + void propagate_present_field(const int); void fill_results_table(const int); void fill_gmatrix_table(spacetime::vector &) const; diff --git a/src/interactions/AIM/nearfield.cpp b/src/interactions/AIM/nearfield.cpp index 07495e63..80369a66 100644 --- a/src/interactions/AIM/nearfield.cpp +++ b/src/interactions/AIM/nearfield.cpp @@ -30,8 +30,7 @@ AIM::Nearfield::Nearfield( { } -const InteractionBase::ResultArray & -AIM::Nearfield::first_evaluation_of_timestep(const int time_idx) +const InteractionBase::ResultArray &AIM::Nearfield::evaluate(const int time_idx) { constexpr int RH0_01 = 1; @@ -67,7 +66,8 @@ AIM::Nearfield::first_evaluation_of_timestep(const int time_idx) return results; } -const InteractionBase::ResultArray &AIM::Nearfield::evaluate(const int time_idx) +const InteractionBase::ResultArray &AIM::Nearfield::evaluate_present_field( + const int time_idx) { constexpr int RH0_01 = 1; diff --git a/src/interactions/AIM/nearfield.h b/src/interactions/AIM/nearfield.h index 40ffe959..54c2e6a0 100644 --- a/src/interactions/AIM/nearfield.h +++ b/src/interactions/AIM/nearfield.h @@ -24,7 +24,7 @@ class AIM::Nearfield final : public AimBase { ~Nearfield() = default; const ResultArray &evaluate(const int) final; - const ResultArray &first_evaluation_of_timestep(const int) final; + const ResultArray &evaluate_present_field(const int) final; private: struct support_range_t { diff --git a/src/interactions/direct_interaction.cpp b/src/interactions/direct_interaction.cpp index aa51e90a..2cd24a65 100644 --- a/src/interactions/direct_interaction.cpp +++ b/src/interactions/direct_interaction.cpp @@ -42,8 +42,8 @@ void DirectInteraction::build_coefficient_table( } } -const InteractionBase::ResultArray & -DirectInteraction::first_evaluation_of_timestep(const int time_idx) +const InteractionBase::ResultArray &DirectInteraction::evaluate( + const int time_idx) { constexpr int RHO_01 = 1; results.setZero(); @@ -76,7 +76,7 @@ DirectInteraction::first_evaluation_of_timestep(const int time_idx) return results; } -const InteractionBase::ResultArray &DirectInteraction::evaluate( +const InteractionBase::ResultArray &DirectInteraction::evaluate_present_field( const int time_idx) { constexpr int RHO_01 = 1; diff --git a/src/interactions/direct_interaction.h b/src/interactions/direct_interaction.h index 909f061b..806e5e20 100644 --- a/src/interactions/direct_interaction.h +++ b/src/interactions/direct_interaction.h @@ -14,7 +14,7 @@ class DirectInteraction final : public HistoryInteraction { const double); const ResultArray &evaluate(const int) final; - const ResultArray &first_evaluation_of_timestep(const int) final; + const ResultArray &evaluate_present_field(const int) final; private: int num_interactions; diff --git a/src/interactions/interaction.h b/src/interactions/interaction.h index 35ed2d48..9765333d 100644 --- a/src/interactions/interaction.h +++ b/src/interactions/interaction.h @@ -17,7 +17,7 @@ class InteractionBase { dt(dt){}; // const cmplx &operator[](const int i) const { return results[i]; } virtual const ResultArray &evaluate(const int) = 0; - virtual const ResultArray &first_evaluation_of_timestep(const int) = 0; + virtual const ResultArray &evaluate_present_field(const int) = 0; virtual ~InteractionBase(){}; diff --git a/src/interactions/pulse_interaction.h b/src/interactions/pulse_interaction.h index 5111c156..ae9a849c 100644 --- a/src/interactions/pulse_interaction.h +++ b/src/interactions/pulse_interaction.h @@ -11,7 +11,7 @@ class PulseInteraction : public InteractionBase { const double, const double); virtual const ResultArray &evaluate(const int); - virtual const ResultArray &first_evaluation_of_timestep(const int n) + virtual const ResultArray &evaluate_present_field(const int n) { return evaluate(n); } diff --git a/test/propagator_test.cpp b/test/propagator_test.cpp index 1b66973a..b24fe665 100644 --- a/test/propagator_test.cpp +++ b/test/propagator_test.cpp @@ -73,8 +73,7 @@ BOOST_FIXTURE_TEST_CASE(DIRECT_INTERACTION, SimulationStructures) for(int i = 0; i < num_timesteps; ++i) { BOOST_TEST_MESSAGE(i); - const double obs_val_calculated = - direct_interaction.first_evaluation_of_timestep(i)(1).real(); + const double obs_val_calculated = direct_interaction.evaluate(i)(1).real(); const double obs_val_actual = obs_fn(i * dt); BOOST_REQUIRE_CLOSE_FRACTION(obs_val_calculated, obs_val_actual, 1e-9); } @@ -99,8 +98,7 @@ BOOST_FIXTURE_TEST_CASE(AIM_INTERACTION, SimulationStructures) for(int i = 0; i < num_timesteps; ++i) { BOOST_TEST_MESSAGE(i); - const double obs_val_calculated = - aim_interaction.first_evaluation_of_timestep(i)(1).real(); + const double obs_val_calculated = aim_interaction.evaluate(i)(1).real(); const double obs_val_actual = obs_fn(i * dt); if(i > 16) { From 4817ee216d60b231f551967d0b35ad98708c6444 Mon Sep 17 00:00:00 2001 From: Thomas Bertus Date: Wed, 10 Jun 2020 23:38:14 -0400 Subject: [PATCH 43/43] changed past_terms_of_results to past_terms_of_convolution for pull request #44 --- src/interactions/AIM/direct.cpp | 10 +++++----- src/interactions/AIM/nearfield.cpp | 10 +++++----- src/interactions/direct_interaction.cpp | 10 +++++----- src/interactions/interaction.h | 4 ++-- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/interactions/AIM/direct.cpp b/src/interactions/AIM/direct.cpp index 4dc77a42..7e8baddd 100644 --- a/src/interactions/AIM/direct.cpp +++ b/src/interactions/AIM/direct.cpp @@ -23,7 +23,7 @@ const InteractionBase::ResultArray &AIM::DirectInteraction::evaluate( constexpr int RHO_01 = 1; results.setZero(); - past_terms_of_results.setZero(); + past_terms_of_convolution.setZero(); for(int pair_idx = 0; pair_idx < shape_[0]; ++pair_idx) { const auto &pair = (*interaction_pairs_)[pair_idx]; @@ -33,10 +33,10 @@ const InteractionBase::ResultArray &AIM::DirectInteraction::evaluate( std::max(time_idx - floor_delays_[pair_idx] - i, static_cast(history->array_.index_bases()[1])); - past_terms_of_results[pair.first] += + past_terms_of_convolution[pair.first] += (history->array_[pair.second][s][0])[RHO_01] * coefficients_[pair_idx][i]; - past_terms_of_results[pair.second] += + past_terms_of_convolution[pair.second] += (history->array_[pair.first][s][0])[RHO_01] * coefficients_[pair_idx][i]; } @@ -49,7 +49,7 @@ const InteractionBase::ResultArray &AIM::DirectInteraction::evaluate( results[pair.second] += (history->array_[pair.first][s][0])[RHO_01] * coefficients_[pair_idx][0]; } - results += past_terms_of_results; + results += past_terms_of_convolution; return results; } @@ -71,7 +71,7 @@ AIM::DirectInteraction::evaluate_present_field(const int time_idx) results[pair.second] += (history->array_[pair.first][s][0])[RHO_01] * coefficients_[pair_idx][0]; } - results += past_terms_of_results; + results += past_terms_of_convolution; return results; } diff --git a/src/interactions/AIM/nearfield.cpp b/src/interactions/AIM/nearfield.cpp index 80369a66..bb39b920 100644 --- a/src/interactions/AIM/nearfield.cpp +++ b/src/interactions/AIM/nearfield.cpp @@ -35,7 +35,7 @@ const InteractionBase::ResultArray &AIM::Nearfield::evaluate(const int time_idx) constexpr int RH0_01 = 1; results.setZero(); - past_terms_of_results.setZero(); + past_terms_of_convolution.setZero(); for(int pair_idx = 0; pair_idx < shape_[0]; ++pair_idx) { const auto &pair = (*interaction_pairs_)[pair_idx]; @@ -44,10 +44,10 @@ const InteractionBase::ResultArray &AIM::Nearfield::evaluate(const int time_idx) const int s = std::max( time_idx - t, static_cast(history->array_.index_bases()[1])); - past_terms_of_results[pair.first] += + past_terms_of_convolution[pair.first] += (history->array_[pair.second][s][0])[RHO_01] * coefficients_[pair_idx][t][0]; - past_terms_of_results[pair.second] += + past_terms_of_convolution[pair.second] += (history->array_[pair.first][s][0])[RHO_01] * coefficients_[pair_idx][t][1]; } @@ -61,7 +61,7 @@ const InteractionBase::ResultArray &AIM::Nearfield::evaluate(const int time_idx) results[pair.second] += (history->array_[pair.first][s][0])[RHO_01] * coefficients_[pair_idx][t][1]; } - results += past_terms_of_results; + results += past_terms_of_convolution; return results; } @@ -86,7 +86,7 @@ const InteractionBase::ResultArray &AIM::Nearfield::evaluate_present_field( results[pair.second] += (history->array_[pair.first][s][0])[RHO_01] * coefficients_[pair_idx][t][1]; } - results += past_terms_of_results; + results += past_terms_of_convolution; return results; } diff --git a/src/interactions/direct_interaction.cpp b/src/interactions/direct_interaction.cpp index 2cd24a65..fed7ecaf 100644 --- a/src/interactions/direct_interaction.cpp +++ b/src/interactions/direct_interaction.cpp @@ -47,7 +47,7 @@ const InteractionBase::ResultArray &DirectInteraction::evaluate( { constexpr int RHO_01 = 1; results.setZero(); - past_terms_of_results.setZero(); + past_terms_of_convolution.setZero(); // iterate through all dot pairs for(int pair_idx = 0; pair_idx < num_interactions; ++pair_idx) { @@ -59,9 +59,9 @@ const InteractionBase::ResultArray &DirectInteraction::evaluate( std::max(time_idx - floor_delays[pair_idx] - i, static_cast(history->array_.index_bases()[1])); - past_terms_of_results[src] += + past_terms_of_convolution[src] += (history->array_[obs][s][0])[RHO_01] * coefficients[pair_idx][i]; - past_terms_of_results[obs] += + past_terms_of_convolution[obs] += (history->array_[src][s][0])[RHO_01] * coefficients[pair_idx][i]; } const int s = std::max(time_idx - floor_delays[pair_idx], @@ -72,7 +72,7 @@ const InteractionBase::ResultArray &DirectInteraction::evaluate( results[obs] += (history->array_[src][s][0])[RHO_01] * coefficients[pair_idx][0]; } - results += past_terms_of_results; + results += past_terms_of_convolution; return results; } @@ -95,7 +95,7 @@ const InteractionBase::ResultArray &DirectInteraction::evaluate_present_field( results[obs] += (history->array_[src][s][0])[RHO_01] * coefficients[pair_idx][0]; } - results += past_terms_of_results; + results += past_terms_of_convolution; return results; } diff --git a/src/interactions/interaction.h b/src/interactions/interaction.h index 9765333d..df368fa6 100644 --- a/src/interactions/interaction.h +++ b/src/interactions/interaction.h @@ -13,7 +13,7 @@ class InteractionBase { InteractionBase(const std::shared_ptr dots, const double dt) : dots(std::move(dots)), results(dots ? dots->size() : 0), - past_terms_of_results(dots ? dots->size() : 0), + past_terms_of_convolution(dots ? dots->size() : 0), dt(dt){}; // const cmplx &operator[](const int i) const { return results[i]; } virtual const ResultArray &evaluate(const int) = 0; @@ -24,7 +24,7 @@ class InteractionBase { protected: std::shared_ptr dots; ResultArray results; - ResultArray past_terms_of_results; + ResultArray past_terms_of_convolution; double dt; };