1 /* Copyright (C) 2015 Atsushi Togo */
2 /* All rights reserved. */
3 
4 /* This file is part of phonopy. */
5 
6 /* Redistribution and use in source and binary forms, with or without */
7 /* modification, are permitted provided that the following conditions */
8 /* are met: */
9 
10 /* * Redistributions of source code must retain the above copyright */
11 /*   notice, this list of conditions and the following disclaimer. */
12 
13 /* * Redistributions in binary form must reproduce the above copyright */
14 /*   notice, this list of conditions and the following disclaimer in */
15 /*   the documentation and/or other materials provided with the */
16 /*   distribution. */
17 
18 /* * Neither the name of the phonopy project nor the names of its */
19 /*   contributors may be used to endorse or promote products derived */
20 /*   from this software without specific prior written permission. */
21 
22 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
23 /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
24 /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
25 /* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
26 /* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
27 /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
28 /* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
29 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
30 /* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
31 /* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
32 /* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
33 /* POSSIBILITY OF SUCH DAMAGE. */
34 
35 #include <math.h>
36 #include "phonoc_const.h"
37 #include "phonoc_utils.h"
38 #include "lapack_wrapper.h"
39 
40 #define THZTOEVPARKB 47.992398658977166
41 #define INVSQRT2PI 0.3989422804014327
42 
bose_einstein(const double x,const double t)43 double bose_einstein(const double x, const double t)
44 {
45   return 1.0 / (exp(THZTOEVPARKB * x / t) - 1);
46 }
47 
gaussian(const double x,const double sigma)48 double gaussian(const double x, const double sigma)
49 {
50   return INVSQRT2PI / sigma * exp(-x * x / 2 / sigma / sigma);
51 }
52 
inv_sinh_occupation(const double x,const double t)53 double inv_sinh_occupation(const double x, const double t)
54 {
55   return 1.0 / sinh(x * THZTOEVPARKB / 2 / t);
56 }
57 
58 lapack_complex_double
phonoc_complex_prod(const lapack_complex_double a,const lapack_complex_double b)59 phonoc_complex_prod(const lapack_complex_double a,
60                     const lapack_complex_double b)
61 {
62   lapack_complex_double c;
63   c = lapack_make_complex_double
64     (lapack_complex_double_real(a) * lapack_complex_double_real(b) -
65      lapack_complex_double_imag(a) * lapack_complex_double_imag(b),
66      lapack_complex_double_imag(a) * lapack_complex_double_real(b) +
67      lapack_complex_double_real(a) * lapack_complex_double_imag(b));
68   return c;
69 }
70