Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 5 additions & 4 deletions src/qball/CurrentDensity.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ CurrentDensity::CurrentDensity(const Sample& s, const Wavefunction & wf):

}

void CurrentDensity::update_current(EnergyFunctional & energy_functional, const Wavefunction & dwf){
void CurrentDensity::update_current(EnergyFunctional & energy_functional, const Wavefunction & dwf,bool output){

Wavefunction rwf(wf_);
Wavefunction rdwf(wf_);
Expand Down Expand Up @@ -100,10 +100,11 @@ void CurrentDensity::update_current(EnergyFunctional & energy_functional, const
// TODO: Reduce total current over spin
assert(wf_.nspin() == 1);

if ( wf_.context().onpe0() ){
std::cout << " total_electronic_current:\t" << std::fixed << std::setw( 20 ) << std::setprecision( 12 ) << total_current[0] << '\t' << total_current[1] << '\t' << total_current[2] << std::endl;
if (output){
if ( wf_.context().onpe0() ){
std::cout << " total_electronic_current:\t" << std::fixed << std::setw( 20 ) << std::setprecision( 12 ) << total_current[0] << '\t' << total_current[1] << '\t' << total_current[2] << std::endl;
}
}

}

void CurrentDensity::plot(const Sample * s, const std::string & filename){
Expand Down
4 changes: 3 additions & 1 deletion src/qball/CurrentDensity.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include "Wavefunction.h"
#include "EnergyFunctional.h"
#include "Sample.h"
#include <config.h>
#include <iomanip>

class CurrentDensity : private ChargeDensity
{
Expand All @@ -41,7 +43,7 @@ class CurrentDensity : private ChargeDensity
~CurrentDensity (){
}

void update_current(EnergyFunctional & energy, const Wavefunction & dwf);
void update_current(EnergyFunctional & energy, const Wavefunction & dwf, bool output=true);

void plot(const Sample *, const std::string &);
void plot_vtk(const Sample *, const std::string &);
Expand Down
11 changes: 9 additions & 2 deletions src/qball/EhrenSampleStepper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,13 @@ void EhrenSampleStepper::step(int niter)
QB_Pstart(14,scfloop);
#endif
tmap["total_niter"].start();
//yyf: Update vector field and current from where it stops
if(ef_.vp) {
ef_.vp->propagate(s_.ctrl.tddt*(s_.ctrl.mditer-1), s_.ctrl.tddt);
ef_.vector_potential_changed(compute_stress);
currd_.update_current(ef_, dwf,false);
}

for ( int iter = 0; iter < niter; iter++ )
{

Expand Down Expand Up @@ -357,7 +364,7 @@ void EhrenSampleStepper::step(int niter)

tmap["current"].start();
currd_.update_current(ef_, dwf);
tmap["current"].start();
tmap["current"].stop();

if(ef_.vp && oncoutpe){
std::cout << "<!-- vector_potential: " << ef_.vp->value() << " -->\n";
Expand Down Expand Up @@ -477,7 +484,7 @@ void EhrenSampleStepper::step(int niter)
wf_stepper->preupdate();
tmap["preupdate"].stop();

if(ef_.vp) ef_.vp->propagate(s_.ctrl.tddt*(iter + 1), s_.ctrl.tddt);
if(ef_.vp) ef_.vp->propagate(s_.ctrl.tddt*s_.ctrl.mditer, s_.ctrl.tddt);

tmap["ionic"].start();
if ( atoms_move )
Expand Down