Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
0cf0263
Add .travis.yml file
rayhem Oct 27, 2018
52156fb
Update travis to build with cmake
rayhem Oct 27, 2018
5c14ee1
Get eigen package
rayhem Oct 27, 2018
0d44ffb
Remove eigen deb package; include boost dependencies
rayhem Oct 27, 2018
1357e27
Manually get and build eigen package
rayhem Oct 27, 2018
33fae63
Actually run the eigen getter script
rayhem Oct 27, 2018
d967f2a
Build Eigen with sudo
rayhem Oct 30, 2018
7d9ee0f
Fix up get eigen script
rayhem Oct 30, 2018
417f800
Mark as executable
rayhem Oct 30, 2018
a7bfe54
Get boost
rayhem Oct 30, 2018
91d6b8a
Quiet logs
rayhem Oct 30, 2018
eda915d
Debugging get boost
rayhem Nov 2, 2018
32577f8
well crap.
rayhem Nov 2, 2018
28c92a0
changes
rayhem Nov 2, 2018
75dce9f
formating
tbertus Oct 3, 2019
2cec272
Eliminated redundant calls to bloch_rhs' evaluate during corrector
tbertus May 19, 2020
6ba5f6f
the way to win on rainbow road
tbertus May 26, 2020
9961c14
listing what's in the boost directory
tbertus May 26, 2020
492cb9c
added .sh to ./bootstrap.sh in get_boost.sh
tbertus May 26, 2020
616d85e
changed make qtest to make qtest-bin and commented out anything relat…
tbertus May 26, 2020
102ceb1
trying to get rapidcheck to work. submodules are pretty cool
tbertus May 26, 2020
7cbdc23
automatic boost install
tbertus May 27, 2020
10c54d8
trying to install boost automatically
tbertus May 27, 2020
96ebe23
other changes
tbertus May 27, 2020
8ccb2f0
temporarily removed some unit tests
tbertus May 27, 2020
d331aff
temporarily removed some unit tests
tbertus May 27, 2020
42db27e
installing eigen through apt
tbertus May 27, 2020
85d3b3f
boost / eigen versions available through apt do not work well with ra…
tbertus May 27, 2020
b0af103
Merge branch 'travis' into development
tbertus May 29, 2020
9fe8f2f
added pass/fail flag to README.md
tbertus May 29, 2020
c23b752
working on badg
tbertus May 29, 2020
f8777e0
markdown troubles
tbertus May 29, 2020
7e5be99
try to get submodule to work with travis
tbertus May 29, 2020
afed5c6
initialize rapidcheck submodule
tbertus May 29, 2020
17697fb
removed first_call flag in favor of two seperate functions
tbertus Jun 1, 2020
ca8168c
reintroducing some unit tests
tbertus Jun 1, 2020
42948a6
including unit test
tbertus Jun 2, 2020
e74e86d
corrected submodule location
tbertus Jun 2, 2020
66cc336
trying to get travis CI to work
tbertus Jun 2, 2020
3bf248c
trying to get rapidcheck to work with travis on this branch
tbertus Jun 2, 2020
54c8771
removed unneeded comments
tbertus Jun 2, 2020
47bbd65
remove old code
tbertus Jun 2, 2020
6b9308a
renamed evaluate functions of rhs and interaction classes
tbertus Jun 11, 2020
4817ee2
changed past_terms_of_results to past_terms_of_convolution for pull r…
tbertus Jun 11, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "extra/rapidcheck"]
path = extras/rapidcheck
[submodule "rapidcheck"]
path = rapidcheck
url = https://github.com/emil-e/rapidcheck.git
24 changes: 24 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
language: cpp
compiler:
#- clang
- gcc

before_script:
- sudo ./install/get_boost.sh > /dev/null
- sudo ./install/get_eigen.sh > /dev/null
- mkdir build && cd build
- cmake ..

script: make qtest-bin && ./qtest

addons:
apt:
sources:
- george-edison55-precise-backports
packages:
- cmake-data
- cmake
- libfftw3-dev
#- libeigen3-dev
#- libboost-test-dev
#- libboost-program-options-dev
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)](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)

# QuEST: The Quantum Electromagnetics Simulation Toolbox
Expand Down
1 change: 0 additions & 1 deletion extras/rapidcheck
Submodule rapidcheck deleted from 624fe9
14 changes: 14 additions & 0 deletions install/get_boost.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/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 > /dev/null
ls

echo "Building boost"
cd boost/
ls
./bootstrap.sh --with-libraries=program_options,test
./b2 install
5 changes: 5 additions & 0 deletions install/get_eigen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
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
29 changes: 23 additions & 6 deletions src/integrator/RHS/bloch_rhs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ 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<InteractionBase> &interaction) {
return r + interaction->evaluate(step);
};
auto eval_and_sum = [step](
const InteractionBase::ResultArray &r,
const std::shared_ptr<InteractionBase> &interaction) {
return r + interaction->evaluate_present_field(step);
};
auto nil = InteractionBase::ResultArray::Zero(num_solutions, 1).eval();

auto projected_efields = std::accumulate(
Expand All @@ -28,5 +28,22 @@ void Integrator::BlochRHS::evaluate(const int step) const
history->array_[solution][step][1] = rhs_functions[solution](
history->array_[solution][step][0], projected_efields[solution]);
}
}

void Integrator::BlochRHS::evaluate(const int step) const
{
auto eval_and_sum = [step](
const InteractionBase::ResultArray &r,
const std::shared_ptr<InteractionBase> &interaction) {
return r + interaction->evaluate(step);
};
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]);
}
}
1 change: 1 addition & 0 deletions src/integrator/RHS/bloch_rhs.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Integrator::BlochRHS : public Integrator::RHS<Eigen::Vector2cd> {
const std::shared_ptr<History<Eigen::Vector2cd>>,
std::vector<std::shared_ptr<InteractionBase>>,
std::vector<BlochFunctionType>);
void evaluate_present(const int) const override;
void evaluate(const int) const override;

private:
Expand Down
6 changes: 5 additions & 1 deletion src/integrator/RHS/ode_rhs.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ namespace Integrator {

class Integrator::ODE_RHS : public RHS<double> {
public:
ODE_RHS(const double, const std::shared_ptr<Integrator::History<double>>,
ODE_RHS(const double,
const std::shared_ptr<Integrator::History<double>>,
const std::vector<std::function<double(double, double)>>);
void evaluate_present(const int) const;
void evaluate(const int) const;

private:
Expand All @@ -36,4 +38,6 @@ void Integrator::ODE_RHS::evaluate(const int n) const
}
}

void Integrator::ODE_RHS::evaluate_present(const int n) const { evaluate(n); }

#endif
1 change: 1 addition & 0 deletions src/integrator/RHS/rhs.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Integrator::RHS {
public:
RHS(const double dt, const std::shared_ptr<History<soltype>> history)
: dt(dt), history(std::move(history)){};
virtual void evaluate_present(const int) const = 0;
virtual void evaluate(const int) const = 0;

protected:
Expand Down
2 changes: 1 addition & 1 deletion src/integrator/integrator.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void Integrator::PredictorCorrector<soltype>::solve_step(const int step) const

for(int m = 0; m < num_corrector_steps; ++m) {
corrector(step);
rhs->evaluate(step);
rhs->evaluate_present(step);
}
}

Expand Down
10 changes: 9 additions & 1 deletion src/interactions/AIM/aim_interaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,20 @@ class AIM::Interaction final : public InteractionBase {

const ResultArray &evaluate(const int t)
{
// I DON'T KNOW WHY THAT NEEDS A CONJUGATE!!!
results =
(ff.evaluate(t).conjugate() - nf.evaluate(t)) + direct.evaluate(t);
return results;
}

const ResultArray &evaluate_present_field(const int t)
{
// I DON'T KNOW WHY THAT NEEDS A CONJUGATE!!!
results = (ff.evaluate_present_field(t).conjugate() -
nf.evaluate_present_field(t)) +
direct.evaluate_present_field(t);
return results;
}

private:
std::shared_ptr<Grid> grid;
std::shared_ptr<Expansions::ExpansionTable> expansion_table;
Expand Down
47 changes: 40 additions & 7 deletions src/interactions/AIM/direct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,58 @@ AIM::DirectInteraction::DirectInteraction(
const InteractionBase::ResultArray &AIM::DirectInteraction::evaluate(
const int time_idx)
{
constexpr int RHO_01 = 1;

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];

for(int i = 0; i < shape_[1]; ++i) {
for(int i = 1; i < shape_[1]; ++i) {
const int s =
std::max(time_idx - floor_delays_[pair_idx] - i,
static_cast<int>(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];
past_terms_of_convolution[pair.first] +=
(history->array_[pair.second][s][0])[RHO_01] *
coefficients_[pair_idx][i];
past_terms_of_convolution[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<int>(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_convolution;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be return results + past_terms_of_convolution? If evaluate is called, and then evaluate_present_field is called, results gets multiple "presents" added to it, no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

results is set to zero at the top of evaluate_present_field so it has the contribution of a one "present" at a time. As a matter of curiosity, because the function returns a reference, would return results + past_terms_of_convolution work?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, ok - that makes sense. There's still something I'm not seeing, though; ultimately I think evaluate is really just past_part + present_part. You've moved the logic for present_part into the other function but you don't call it here so I'm not sure what your intention is.

And you're exactly right: using return results + past; returns what's called an "rvalue" (so a reference to it is invalid). Coding it that way would require changing the function signature.

Copy link
Collaborator Author

@tbertus tbertus Jun 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure I follow. As of now, evaluate computes and stores the past and adds it to the present. evaluate_present_field zeros out results computes the updated present contribution and adds it to the past_part that was calculated by evaluate

Copy link
Owner

@cglosser cglosser Jun 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, so, in my head evaluate should always give you the full field (perhaps inefficiently) because it's the virtual function prescribed by InteractionBase. "An interaction can always be evaluated", so to speak, and you may not need the complexity of divorcing the past update from the present update (if, say, you're not using something as sophisticated as the predictor/corrector). So I think a good design here would be to implement two methods, ResultArray &AIM::DirectInteraction::evaluate_past and resultArray &AIM::DirectInteraction::evaluate_present, that each populate an internal array of known size (like results). Then you'll have something like this:

const InteractionBase::ResultArray &AIM::DirectInteraction::evaluate(const int time_idx) {
    evaluate_past(time_idx);
    evaluate_present(time_idx);
    results = past_results + present_results;
    return results;
}

and

const InteractionBase::ResultArray &AIM::DirectInteraction::evaluate_present(const int time_idx) {
    // Assumes evaluate_past has already been called for this time_idx
 
    // <Logic for present update>
    results = past_results + present_results;
    return results;
}

To do this, it may make sense to hoist evaluate_past and evaluate_present into InteractionBase as pure virtual functions. This would be the case if every Interaction that ever exists must define those functions to make sense (which is probably the case).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that would be a good way to set things up. But to be clear evaluate can currently be used independent of evaluate_present_field. The functionality of evaluate now is the same as it was originally with the added side effect of storing past_results.

return results;
}

const InteractionBase::ResultArray &
AIM::DirectInteraction::evaluate_present_field(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<int>(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_convolution;
return results;
}

Expand Down
1 change: 1 addition & 0 deletions src/interactions/AIM/direct.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class AIM::DirectInteraction final : public HistoryInteraction {
std::shared_ptr<const std::vector<Grid::ipair_t>>);

const ResultArray &evaluate(const int) final;
const ResultArray &evaluate_present_field(const int) final;
boost::multi_array<cmplx, 2> coefficient_table(Propagation::Kernel<cmplx> &,
std::vector<int> &) const;

Expand Down
45 changes: 43 additions & 2 deletions src/interactions/AIM/farfield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,59 @@ void AIM::Farfield::propagate(const int step)

Eigen::Map<Eigen::Array3Xcd> observers(&obs_table_(front), 3, nb);
observers = 0;
// initialize temp_observers with the correct size and zero it
temp_observers = Eigen::Array3Xcd::Zero(3, nb);

for(int i = 0; i < table_dimensions_[0]; ++i) {
// 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<Eigen::ArrayXcd> prop(&propagation_table_[i][0][0][0], nb);
Eigen::Map<Eigen::Array3Xcd> 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();
temp_observers += src.rowwise() * prop.transpose();
}

// set observers equal to temp_observers
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't repeat code in comments; why do you need to 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<Eigen::ArrayXcd> prop(&propagation_table_[0][0][0][0], nb);
Eigen::Map<Eigen::Array3Xcd> 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<fftw_complex *>(o_ptr),
reinterpret_cast<fftw_complex *>(o_ptr));
}

void AIM::Farfield::propagate_present_field(const int step)
{
const auto wrapped_step = step % table_dimensions_[0];
const auto nb = 8 * grid->size();
const std::array<int, 5> front = {{wrapped_step, 0, 0, 0, 0}};

const auto s_ptr = &source_table_(front);
fftw_execute_dft(spatial_vector_transforms_.forward,
reinterpret_cast<fftw_complex *>(s_ptr),
reinterpret_cast<fftw_complex *>(s_ptr));

Eigen::Map<Eigen::Array3Xcd> observers(&obs_table_(front), 3, nb);
observers = 0;

observers += temp_observers;

auto wrap = std::max(step, 0) % table_dimensions_[0]; // needed ?

Eigen::Map<Eigen::ArrayXcd> prop(&propagation_table_[0][0][0][0], nb);
Eigen::Map<Eigen::Array3Xcd> 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<fftw_complex *>(o_ptr),
Expand Down
12 changes: 11 additions & 1 deletion src/interactions/AIM/farfield.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,19 @@ class AIM::Farfield final : public AimBase {
Normalization::SpatialNorm);
~Farfield() = default;

const ResultArray &evaluate_present_field(const int step) final
{
fill_source_table(step);
propagate_present_field(step);
fill_results_table(step);

return results;
}
const ResultArray &evaluate(const int step) final
{
fill_source_table(step);
propagate(step);
fill_results_table(step);

return results;
}

Expand All @@ -39,11 +46,14 @@ class AIM::Farfield final : public AimBase {
spacetime::vector<cmplx> propagation_table_;
spacetime::vector3d<cmplx> source_table_, obs_table_;

Eigen::Array3Xcd temp_observers;

TransformPair spatial_vector_transforms_;

spacetime::vector<cmplx> make_propagation_table() const;
void fill_source_table(const int);
void propagate(const int);
void propagate_present_field(const int);
void fill_results_table(const int);

void fill_gmatrix_table(spacetime::vector<cmplx> &) const;
Expand Down
Loading