Skip to content

Commit

Permalink
bug: fixed winding number issue for non-PBC
Browse files Browse the repository at this point in the history
feature: extending S(Q) functionality
  • Loading branch information
agdelma committed Dec 9, 2021
1 parent cc32418 commit a1d7fa9
Show file tree
Hide file tree
Showing 5 changed files with 176 additions and 215 deletions.
26 changes: 26 additions & 0 deletions include/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <algorithm>
#include <sstream>
#include <chrono>
#include <tuple>
#include <functional> // has std::bind

#define BZ_HAVE_BOOST_SERIALIZATION
Expand Down Expand Up @@ -145,4 +146,29 @@ inline Ttype& min(Ttype& x, Ttype& y) { return (x < y ? x : y); }
template<typename Ttype>
inline Ttype& max(Ttype& x, Ttype& y) { return (x > y ? x : y); }

/** A python-like enumerate
* @see https://www.reedbeta.com/blog/python-like-enumerate-in-cpp17/
* */
template <typename T,
typename TIter = decltype(std::begin(std::declval<T>())),
typename = decltype(std::end(std::declval<T>()))>
constexpr auto enumerate(T && iterable)
{
struct iterator
{
size_t i;
TIter iter;
bool operator != (const iterator & other) const { return iter != other.iter; }
void operator ++ () { ++i; ++iter; }
auto operator * () const { return std::tie(i, *iter); }
};
struct iterable_wrapper
{
T iterable;
auto begin() { return iterator{ 0, std::begin(iterable) }; }
auto end() { return iterator{ 0, std::end(iterable) }; }
};
return iterable_wrapper{ std::forward<T>(iterable) };
}

#endif
9 changes: 3 additions & 6 deletions include/estimator.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ class EstimatorBase {
/* Initialize the estimator */
void initialize(int);
void initialize(vector<string>);

/* generate q-vectors needed for momentum space estimators */
vector <vector<dVec> > getQVectors(double, int, string);
};

// ========================================================================
Expand Down Expand Up @@ -727,9 +730,6 @@ class StaticStructureFactorEstimator: public EstimatorBase {
private:
void accumulate(); // Accumulate values
Array <double,1> sf; // structure factor
Array <double,1> qMag; // the q-vector magnitudes
int numq; // number of q values
Array <int,1> numqVecs; // the number of q-vectors with a given magnitude
vector <vector<dVec> > q; // the q-vectors
};

Expand Down Expand Up @@ -1066,9 +1066,6 @@ class CylinderStaticStructureFactorEstimator: public EstimatorBase {
private:
void accumulate(); // Accumulate values
Array <double,1> sf; // structure factor
Array <double,1> qMag; // the q-vector magnitudes
int numq; // number of q values
Array <int,1> numqVecs; // the number of q-vectors with a given magnitude
vector <vector<dVec> > q; // the q-vectors
};

Expand Down
1 change: 0 additions & 1 deletion include/move.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ class MoveBase {
Array <dVec,1> newPos; ///< New particle positions

vector <iVec> winding; ///< The winding vectors
vector <int> windingSector; ///< Used to index different winding sectors
vector <double> cumrho0; ///< Used for tower-sampling winding sectors

int maxWind; ///< The largest winding number
Expand Down
Loading

0 comments on commit a1d7fa9

Please sign in to comment.