24 #ifndef COM_DAFER45_TBTK_TIME_EVOLVER
25 #define COM_DAFER45_TBTK_TIME_EVOLVER
38 class TimeEvolver :
public Solver{
44 virtual ~TimeEvolver();
53 void setCallback(
bool (*callback)(TimeEvolver *timeEvolver));
56 void setMaxSCIterations(
int maxIterations);
59 void setNumTimeSteps(
int numTimeSteps);
62 void setTimeStep(
double dt);
71 void setNumberOfParticles(
int numberOfParticles);
74 int getNumberOfParticles();
78 void fixParticleNumber(
bool particleNumberIsFixed);
81 double getOccupancy(
int state);
85 Diagonalizer *getDiagonalizer();
88 double getEigenValue(
int state);
94 const std::complex<double> getAmplitude(
int state,
const Index &index);
109 enum class DecayMode{None, Instantly, Interpolate, Custom};
112 void setDecayMode(DecayMode decayMode);
117 TimeEvolver *timeEvolver,
120 std::complex<double> **eigenVectorsMap
126 void setDecayHandler(DecayHandler *decayHandler);
130 int getCurrentTimeStep();
135 void setOrthogonalityCheckInterval(
int orthogonalityCheckInterval);
138 double getOrthogonalityError();
143 Diagonalizer dSolver;
149 std::complex<double> *eigenVectors;
155 std::complex<double> **eigenVectorsMap;
161 int numberOfParticles;
165 bool particleNumberIsFixed;
171 DecayHandler *decayHandler;
175 bool (*callback)(TimeEvolver *timeEvolver);
189 static std::vector<TimeEvolver*> timeEvolvers;
194 static std::vector<Diagonalizer*> dSolvers;
201 class SelfConsistencyCallback :
202 public Diagonalizer::SelfConsistencyCallback
205 virtual bool selfConsistencyCallback(Diagonalizer &diagonalizer);
208 static SelfConsistencyCallback selfConsistencyCallback;
212 void onDiagonalizationFinished();
219 void updateOccupancy();
222 void decayInstantly();
225 void decayInterpolate();
229 double orthogonalityError;
233 int orthogonalityCheckInterval;
236 void calculateOrthogonalityError();
239 inline void TimeEvolver::setCallback(
240 bool (*callback)(TimeEvolver *timeEvolver)
242 this->callback = callback;
245 inline void TimeEvolver::setMaxSCIterations(
int maxIterations){
246 dSolver.setMaxIterations(maxIterations);
249 inline void TimeEvolver::setNumTimeSteps(
int numTimeSteps){
250 this->numTimeSteps = numTimeSteps;
253 inline void TimeEvolver::setTimeStep(
double dt){
257 inline void TimeEvolver::setNumberOfParticles(
int numberOfParticles){
258 this->numberOfParticles = numberOfParticles;
261 inline int TimeEvolver::getNumberOfParticles(){
262 return numberOfParticles;
265 inline void TimeEvolver::fixParticleNumber(
bool particleNumberIsFixed){
266 this->particleNumberIsFixed = particleNumberIsFixed;
269 inline Diagonalizer* TimeEvolver::getDiagonalizer(){
273 inline double TimeEvolver::getEigenValue(
int state){
274 return eigenValues[state];
277 inline double TimeEvolver::getOccupancy(
int state){
278 return occupancy[state];
281 inline const std::complex<double> TimeEvolver::getAmplitude(
285 return eigenVectorsMap[state][getModel().getBasisIndex(index)];
288 inline void TimeEvolver::setDecayMode(DecayMode decayMode){
289 this->decayMode = decayMode;
292 inline void TimeEvolver::setDecayHandler(DecayHandler *decayHandler){
293 this->decayHandler = decayHandler;
296 inline int TimeEvolver::getCurrentTimeStep(){
297 return currentTimeStep;
300 inline void TimeEvolver::setOrthogonalityCheckInterval(
301 int orthogonalityCheckInterval
303 this->orthogonalityCheckInterval = orthogonalityCheckInterval;
306 inline double TimeEvolver::getOrthogonalityError(){
307 return orthogonalityError;