Skip to content

Commit

Permalink
...EJB
Browse files Browse the repository at this point in the history
  • Loading branch information
ebylaska committed Dec 6, 2023
1 parent 2a2c3f0 commit 78e92c1
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 96 deletions.
6 changes: 3 additions & 3 deletions Nwpw/band/cpsd/band_cpsd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "CStrfac.hpp"
#include "util_date.hpp"
#include "band_inner_loop.hpp"
//#include "nwpw_aimd_running_cdata.hpp"
#include "nwpw_aimd_running_data.hpp"
#include "mpi.h"

//#include "gdevice.hpp"
Expand Down Expand Up @@ -334,7 +334,7 @@ int band_cpsd(MPI_Comm comm_world0, std::string &rtdbstring)
if (control.loop(1) > 0) {

// Initialize AIMD running data
//nwpw_aimd_running_cdata mymotion_data(control,&myparallel,&mygrid,&myion,E,hml,psi1,dn);
nwpw_aimd_running_data mymotion_data(control,&myparallel,&mylattice,&myion,E,hml,psi1,dn);

done = 0;
icount = 0;
Expand All @@ -348,7 +348,7 @@ int band_cpsd(MPI_Comm comm_world0, std::string &rtdbstring)
// mydfpt.start(psi1,psi_r

// Update AIMD Running data
//if (control.geometry_optimize()) mymotion_data.update_iteration(icount);
if (control.geometry_optimize()) mymotion_data.update_iteration(icount);


if (oprint)
Expand Down
86 changes: 44 additions & 42 deletions Nwpw/nwpwlib/aimd_analysis/nwpw_aimd_running_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <cstdio>
#include <cstring>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <iostream>
#include <sys/stat.h>
Expand Down Expand Up @@ -74,12 +75,13 @@ namespace pwdft {
* nwpw_aimd_running_data::nwpw_aimd_running_data *
* *
****************************************************/
nwpw_aimd_running_data::nwpw_aimd_running_data(Control2 &control, Parallel *inparall, Pneb *inpneb, Ion *inion,
nwpw_aimd_running_data::nwpw_aimd_running_data(Control2 &control, Parallel *inparall, Lattice *inlattice, Ion *inion,
double *Ein, double *hmlin, double *psiin, double *dnin)
{
myparall = inparall;
myion = inion;
mypneb = inpneb;
myparall = inparall;
mylattice = inlattice;
myion = inion;

E = Ein;
hml = hmlin;
psi = psiin;
Expand Down Expand Up @@ -282,15 +284,15 @@ void nwpw_aimd_running_data::update_iteration(const int icount)
{
double AACONV = 0.529177;

double a1x = mypneb->lattice->unita(0,0)*AACONV;
double a1y = mypneb->lattice->unita(1,0)*AACONV;
double a1z = mypneb->lattice->unita(2,0)*AACONV;
double a2x = mypneb->lattice->unita(0,1)*AACONV;
double a2y = mypneb->lattice->unita(1,1)*AACONV;
double a2z = mypneb->lattice->unita(2,1)*AACONV;
double a3x = mypneb->lattice->unita(0,2)*AACONV;
double a3y = mypneb->lattice->unita(1,2)*AACONV;
double a3z = mypneb->lattice->unita(2,2)*AACONV;
double a1x = mylattice->unita(0,0)*AACONV;
double a1y = mylattice->unita(1,0)*AACONV;
double a1z = mylattice->unita(2,0)*AACONV;
double a2x = mylattice->unita(0,1)*AACONV;
double a2y = mylattice->unita(1,1)*AACONV;
double a2z = mylattice->unita(2,1)*AACONV;
double a3x = mylattice->unita(0,2)*AACONV;
double a3y = mylattice->unita(1,2)*AACONV;
double a3z = mylattice->unita(2,2)*AACONV;

*xyz << myion->nion << std::endl
<< hxyzstream(a1x, a1y, a1z, a2x, a2y, a2z, a3x, a3y, a3z)
Expand All @@ -312,16 +314,16 @@ void nwpw_aimd_running_data::update_iteration(const int icount)
{
double current_time = dt_inner * (icount + ion_motion_ishift);

double omega = mypneb->lattice->omega();
double a1x = mypneb->lattice->unita(0,0);
double a1y = mypneb->lattice->unita(1,0);
double a1z = mypneb->lattice->unita(2,0);
double a2x = mypneb->lattice->unita(0,1);
double a2y = mypneb->lattice->unita(1,1);
double a2z = mypneb->lattice->unita(2,1);
double a3x = mypneb->lattice->unita(0,2);
double a3y = mypneb->lattice->unita(1,2);
double a3z = mypneb->lattice->unita(2,2);
double omega = mylattice->omega();
double a1x = mylattice->unita(0,0);
double a1y = mylattice->unita(1,0);
double a1z = mylattice->unita(2,0);
double a2x = mylattice->unita(0,1);
double a2y = mylattice->unita(1,1);
double a2z = mylattice->unita(2,1);
double a3x = mylattice->unita(0,2);
double a3y = mylattice->unita(1,2);
double a3z = mylattice->unita(2,2);

*ion_motion << hionstream(current_time,myion->nion,omega,
a1x,a1y,a1z,a2x,a2y,a2z,a3x,a3y,a3z)
Expand Down Expand Up @@ -372,15 +374,15 @@ void nwpw_aimd_running_data::update_iteration(const int icount)
// Running fei
if (fei_open)
{
double a1x = mypneb->lattice->unita(0,0);
double a1y = mypneb->lattice->unita(1,0);
double a1z = mypneb->lattice->unita(2,0);
double a2x = mypneb->lattice->unita(0,1);
double a2y = mypneb->lattice->unita(1,1);
double a2z = mypneb->lattice->unita(2,1);
double a3x = mypneb->lattice->unita(0,2);
double a3y = mypneb->lattice->unita(1,2);
double a3z = mypneb->lattice->unita(2,2);
double a1x = mylattice->unita(0,0);
double a1y = mylattice->unita(1,0);
double a1z = mylattice->unita(2,0);
double a2x = mylattice->unita(0,1);
double a2y = mylattice->unita(1,1);
double a2z = mylattice->unita(2,1);
double a3x = mylattice->unita(0,2);
double a3y = mylattice->unita(1,2);
double a3z = mylattice->unita(2,2);
*fei << myion->nion << std::endl
<< F206 << E[1] << std::endl
<< F105 << a1x << F105 << a1y << F105 << a1z << std::endl
Expand All @@ -401,16 +403,16 @@ void nwpw_aimd_running_data::update_iteration(const int icount)
double shift = 0.0;
if (cif_shift_cell) shift = 0.5;

double omega = mypneb->lattice->omega();
double a1x = mypneb->lattice->unita(0,0);
double a1y = mypneb->lattice->unita(1,0);
double a1z = mypneb->lattice->unita(2,0);
double a2x = mypneb->lattice->unita(0,1);
double a2y = mypneb->lattice->unita(1,1);
double a2z = mypneb->lattice->unita(2,1);
double a3x = mypneb->lattice->unita(0,2);
double a3y = mypneb->lattice->unita(1,2);
double a3z = mypneb->lattice->unita(2,2);
double omega = mylattice->omega();
double a1x = mylattice->unita(0,0);
double a1y = mylattice->unita(1,0);
double a1z = mylattice->unita(2,0);
double a2x = mylattice->unita(0,1);
double a2y = mylattice->unita(1,1);
double a2z = mylattice->unita(2,1);
double a3x = mylattice->unita(0,2);
double a3y = mylattice->unita(1,2);
double a3z = mylattice->unita(2,2);

double bx1 = (a2y*a3z - a2z*a3y)/omega;
double by1 = (a2z*a3x - a2x*a3z)/omega;
Expand Down
106 changes: 58 additions & 48 deletions Nwpw/nwpwlib/aimd_analysis/nwpw_aimd_running_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@
#include "Control2.hpp"
#include "Ion.hpp"
#include "Parallel.hpp"
#include "Pneb.hpp"
#include "Lattice.hpp"
//#include "gdevice.hpp"

namespace pwdft {

class nwpw_aimd_running_data {

Parallel *myparall;
Pneb *mypneb;
Lattice *mylattice;

Ion *myion;
double *E, *hml, *psi, *dn;

Expand Down Expand Up @@ -71,54 +72,63 @@ class nwpw_aimd_running_data {
double dt, dt_inner, eave, evar, have, hvar, qave, qvar, emotion_time_shift;

/* constructor */
nwpw_aimd_running_data(Control2 &, Parallel *, Pneb *, Ion *, double *,
double *, double *, double *);
nwpw_aimd_running_data(Control2 &, Parallel *, Lattice *, Ion *, double *, double *, double *, double *);

/* destructor */
~nwpw_aimd_running_data() {
// remove bakfiles
this->remove_bakfiles();

// close open files
if (xyz_open) {
xyz->close();
delete xyz;
}
if (ion_motion_open) {
ion_motion->close();
delete ion_motion;
}
if (emotion_open) {
emotion->close();
delete emotion;
}

if (fei_open) {
fei->close();
delete fei;
}
if (cif_open) {
cif->close();
delete cif;
}

if (dipole_motion_open) {
dipole_motion->close();
delete dipole_motion;
}

if (hmotion_open) {
hmotion->close();
delete hmotion;
}
if (omotion_open) {
omotion->close();
delete omotion;
}
if (eigmotion_open) {
eigmotion->close();
delete eigmotion;
}
~nwpw_aimd_running_data()
{
// remove bakfiles
this->remove_bakfiles();

// close open files
if (xyz_open)
{
xyz->close();
delete xyz;
}
if (ion_motion_open)
{
ion_motion->close();
delete ion_motion;
}
if (emotion_open)
{
emotion->close();
delete emotion;
}

if (fei_open)
{
fei->close();
delete fei;
}
if (cif_open)
{
cif->close();
delete cif;
}

if (dipole_motion_open)
{
dipole_motion->close();
delete dipole_motion;
}

if (hmotion_open)
{
hmotion->close();
delete hmotion;
}
if (omotion_open)
{
omotion->close();
delete omotion;
}
if (eigmotion_open)
{
eigmotion->close();
delete eigmotion;
}
}

void update_iteration(const int);
Expand Down
2 changes: 1 addition & 1 deletion Nwpw/pspw/cpsd/cpmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ int cpmd(MPI_Comm comm_world0, std::string &rtdbstring)
if (control.loop(1) > 0)
{
// Initialize AIMD running data
nwpw_aimd_running_data mymotion_data(control,&myparallel,&mygrid,&myion,E,hml,psi1,dn);
nwpw_aimd_running_data mymotion_data(control,&myparallel,&mylattice,&myion,E,hml,psi1,dn);

int it_in = control.loop(0);
verlet = true;
Expand Down
2 changes: 1 addition & 1 deletion Nwpw/pspw/cpsd/cpsd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ int cpsd(MPI_Comm comm_world0, std::string &rtdbstring)
if (control.loop(1) > 0) {

// Initialize AIMD running data
nwpw_aimd_running_data mymotion_data(control,&myparallel,&mygrid,&myion,E,hml,psi1,dn);
nwpw_aimd_running_data mymotion_data(control,&myparallel,&mylattice,&myion,E,hml,psi1,dn);

done = 0;
icount = 0;
Expand Down
2 changes: 1 addition & 1 deletion Nwpw/pspw/minimizer/pspw_bomd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ int pspw_bomd(MPI_Comm comm_world0,std::string &rtdbstring,std::ostream &coutput
coutput << " -----------------------------------------------------------------------\n";
}

nwpw_aimd_running_data mymotion_data(control, &myparallel, &mygrid, &myion, E,
nwpw_aimd_running_data mymotion_data(control, &myparallel, &mylattice, &myion, E,
mymolecule.hml, mymolecule.psi1,
mymolecule.rho1);

Expand Down

0 comments on commit 78e92c1

Please sign in to comment.