Commit 6044d3dc by Maarten L. Hekkelman

Added cif::cell::get_volume()

parent 29446f21
Version 5.2.3 Version 5.2.3
- New constructors for cif::item, one taking std::optional values - New constructors for cif::item, one taking std::optional values
and another taking only a name resulting in a value '.' (i.e. inapplicable). and another taking only a name resulting in a value '.' (i.e. inapplicable).
- added cif::cell::get_volume
Version 5.2.2 Version 5.2.2
- Remove dependency on Eigen3 for users of libcifpp - Remove dependency on Eigen3 for users of libcifpp
......
...@@ -397,6 +397,8 @@ class cell ...@@ -397,6 +397,8 @@ class cell
float get_beta() const { return m_beta; } ///< return angle beta float get_beta() const { return m_beta; } ///< return angle beta
float get_gamma() const { return m_gamma; } ///< return angle gamma float get_gamma() const { return m_gamma; } ///< return angle gamma
float get_volume() const; ///< return the calculated volume for this cell
matrix3x3<float> get_orthogonal_matrix() const { return m_orthogonal; } ///< return the matrix to use to transform coordinates from fractional to orthogonal matrix3x3<float> get_orthogonal_matrix() const { return m_orthogonal; } ///< return the matrix to use to transform coordinates from fractional to orthogonal
matrix3x3<float> get_fractional_matrix() const { return m_fractional; } ///< return the matrix to use to transform coordinates from orthogonal to fractional matrix3x3<float> get_fractional_matrix() const { return m_fractional; } ///< return the matrix to use to transform coordinates from orthogonal to fractional
......
...@@ -80,6 +80,22 @@ void cell::init() ...@@ -80,6 +80,22 @@ void cell::init()
m_fractional = inverse(m_orthogonal); m_fractional = inverse(m_orthogonal);
} }
float cell::get_volume() const
{
auto alpha = (m_alpha * kPI) / 180;
auto beta = (m_beta * kPI) / 180;
auto gamma = (m_gamma * kPI) / 180;
auto cos_alpha = std::cos(alpha);
auto cos_beta = std::cos(beta);
auto cos_gamma = std::cos(gamma);
auto vol = m_a * m_b * m_c;
vol *= std::sqrt(1.0f - cos_alpha * cos_alpha - cos_beta * cos_beta - cos_gamma * cos_gamma + 2.0f * cos_alpha * cos_beta * cos_gamma);
return vol;
}
// -------------------------------------------------------------------- // --------------------------------------------------------------------
sym_op::sym_op(std::string_view s) sym_op::sym_op(std::string_view s)
......
...@@ -565,8 +565,6 @@ BOOST_AUTO_TEST_CASE(symm_2bi3_1a, *utf::tolerance(0.1f)) ...@@ -565,8 +565,6 @@ BOOST_AUTO_TEST_CASE(symm_2bi3_1a, *utf::tolerance(0.1f))
} }
} }
BOOST_AUTO_TEST_CASE(symm_3bwh_1, *utf::tolerance(0.1f)) BOOST_AUTO_TEST_CASE(symm_3bwh_1, *utf::tolerance(0.1f))
{ {
cif::file f(gTestDir / "3bwh.cif.gz"); cif::file f(gTestDir / "3bwh.cif.gz");
...@@ -588,4 +586,16 @@ BOOST_AUTO_TEST_CASE(symm_3bwh_1, *utf::tolerance(0.1f)) ...@@ -588,4 +586,16 @@ BOOST_AUTO_TEST_CASE(symm_3bwh_1, *utf::tolerance(0.1f))
BOOST_TEST(d == distance(a1.get_location(), p)); BOOST_TEST(d == distance(a1.get_location(), p));
} }
} }
} }
\ No newline at end of file
BOOST_AUTO_TEST_CASE(volume_3bwh_1, *utf::tolerance(0.1f))
{
cif::file f(gTestDir / "1juh.cif.gz");
auto &db = f.front();
cif::crystal c(db);
BOOST_CHECK_EQUAL(c.get_cell().get_volume(), 741009.625f);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment