Skip to content
Snippets Groups Projects
Commit edf014d7 authored by mkirsz's avatar mkirsz
Browse files

Added density calculation

parent 8c978f44
No related branches found
No related tags found
1 merge request!17Fix bug when reading stress with vaspreader. Added T to structure and adjusted...
Pipeline #51253 failed
...@@ -137,6 +137,9 @@ struct Structure { ...@@ -137,6 +137,9 @@ struct Structure {
/** @return volume of this structure. */ /** @return volume of this structure. */
double get_volume() const; double get_volume() const;
/** @return density of this structure in g/cm^3 */
double get_density() const;
/** @return virial pressure calculated from the stress tensor. /** @return virial pressure calculated from the stress tensor.
* *
* Units: energy/distance^3 * Units: energy/distance^3
......
...@@ -173,6 +173,14 @@ size_t Structure::get_nn_iindex(const size_t i, const size_t j, const size_t jj) ...@@ -173,6 +173,14 @@ size_t Structure::get_nn_iindex(const size_t i, const size_t j, const size_t jj)
double Structure::get_volume() const { double Structure::get_volume() const {
return cell.row(0)*(cell.row(1).cross(cell.row(2))); return cell.row(0)*(cell.row(1).cross(cell.row(2)));
} }
double Structure::get_density() const {
double V = cell.row(0)*(cell.row(1).cross(cell.row(2)));
V*=1e-24; // convert to cm^3
double amu = 1.66053906660e-24; // g
double mass = 0;
for (const auto& a:atoms) mass += PeriodicTable::get_mass(a.Z);
return amu*mass/V;
}
double Structure::get_virial_pressure() const { double Structure::get_virial_pressure() const {
return stress.trace()/get_volume()/3; return stress.trace()/get_volume()/3;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment