| 1 |
|
#include <cmath> |
| 2 |
+ |
#include <mpi++.h> |
| 3 |
|
|
| 4 |
|
#include "Thermo.hpp" |
| 5 |
|
#include "SRI.hpp" |
| 18 |
|
DirectionalAtom *dAtom; |
| 19 |
|
|
| 20 |
|
int n_atoms; |
| 21 |
+ |
double kinetic_global; |
| 22 |
|
Atom** atoms; |
| 23 |
+ |
|
| 24 |
|
|
| 25 |
|
n_atoms = entry_plug->n_atoms; |
| 26 |
|
atoms = entry_plug->atoms; |
| 27 |
|
|
| 28 |
|
kinetic = 0.0; |
| 29 |
+ |
kinetic_global = 0.0; |
| 30 |
|
for( kl=0; kl < n_atoms; kl++ ){ |
| 31 |
|
|
| 32 |
|
vx2 = atoms[kl]->get_vx() * atoms[kl]->get_vx(); |
| 48 |
|
+ (jz2 / dAtom->getIzz()); |
| 49 |
|
} |
| 50 |
|
} |
| 51 |
< |
|
| 51 |
> |
#ifdef IS_MPI |
| 52 |
> |
MPI_COMM_WORLD.Allreduce(&kinetic,&kinetic_global,1,MPI_DOUBLE,MPI_SUM); |
| 53 |
> |
kinetic = kinetic_global; |
| 54 |
> |
#endif |
| 55 |
> |
|
| 56 |
|
kinetic = kinetic * 0.5 / e_convert; |
| 57 |
|
|
| 58 |
|
return kinetic; |
| 61 |
|
double Thermo::getPotential(){ |
| 62 |
|
|
| 63 |
|
double potential; |
| 64 |
+ |
double potential_global; |
| 65 |
|
int el, nSRI; |
| 66 |
|
SRI** sris; |
| 67 |
|
|
| 69 |
|
nSRI = entry_plug->n_SRI; |
| 70 |
|
|
| 71 |
|
potential = 0.0; |
| 72 |
< |
|
| 72 |
> |
potential_global = 0.0; |
| 73 |
|
potential += entry_plug->longRange->get_potential();; |
| 74 |
|
|
| 75 |
|
// std::cerr << "long range potential: " << potential << "\n"; |
| 67 |
– |
|
| 76 |
|
for( el=0; el<nSRI; el++ ){ |
| 77 |
|
|
| 78 |
|
potential += sris[el]->get_potential(); |
| 79 |
|
} |
| 80 |
|
|
| 81 |
+ |
// Get total potential for entire system from MPI. |
| 82 |
+ |
#ifdef IS_MPI |
| 83 |
+ |
MPI_COMM_WORLD.Allreduce(&potential,&potential_global,1,MPI_DOUBLE,MPI_SUM); |
| 84 |
+ |
potential = potential_global; |
| 85 |
+ |
#endif |
| 86 |
+ |
|
| 87 |
|
return potential; |
| 88 |
|
} |
| 89 |
|
|