SIRIUS 7.5.0
Electronic structure library and applications
symmetrize_stress_tensor.hpp
Go to the documentation of this file.
1// Copyright (c) 2013-2023 Anton Kozhevnikov, Thomas Schulthess
2// All rights reserved.
3//
4// Redistribution and use in source and binary forms, with or without modification, are permitted provided that
5// the following conditions are met:
6//
7// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
8// following disclaimer.
9// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
10// and the following disclaimer in the documentation and/or other materials provided with the distribution.
11//
12// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
13// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
14// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
15// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
16// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
17// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
18// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19
20/** \file symmetrize_stress_tensor.hpp
21 *
22 * \brief Symmetrize lattice stress tensor.
23 */
24
25#ifndef __SYMMETRIZE_STRESS_TENSOR_HPP__
26#define __SYMMETRIZE_STRESS_TENSOR_HPP__
27
28#include "crystal_symmetry.hpp"
29
30namespace sirius {
31
32inline void
33symmetrize_stress_tensor(Crystal_symmetry const& sym__, r3::matrix<double>& s__)
34{
35 if (sym__.size() == 1) {
36 return;
37 }
38
39 r3::matrix<double> result;
40
41 for (int i = 0; i < sym__.size(); i++) {
42 auto R = sym__[i].spg_op.Rcp;
43 result = result + dot(dot(transpose(R), s__), R);
44 }
45
46 s__ = result * (1.0 / sym__.size());
47
48 std::vector<std::array<int, 2>> idx = {{0, 1}, {0, 2}, {1, 2}};
49 for (auto e : idx) {
50 s__(e[0], e[1]) = s__(e[1], e[0]) = 0.5 * (s__(e[0], e[1]) + s__(e[1], e[0]));
51 }
52}
53
54}
55
56#endif
57
Contains definition and partial implementation of sirius::Crystal_symmetry class.
auto transpose(matrix< T > src)
Return transpose of the matrix.
Definition: r3.hpp:445
Namespace of the SIRIUS library.
Definition: sirius.f90:5