18 if (w < 0)
return -
J(-w, w_arr, c_arr,
Nb);
19 if (w_arr ==
nullptr || c_arr ==
nullptr ||
Nb <= 0 || w / w_arr[
Nb - 1] > 0.1)
20 throw std::runtime_error(
"J(w) fitting error!");
22 double a = 10e0 *
Nb *
Nb / (w_arr[
Nb - 1] * w_arr[
Nb - 1]);
24 for (
int j = 0; j <
Nb; ++j) {
25 Jw += c_arr[j] * c_arr[j] / w_arr[j] * std::exp(-a * (w - w_arr[j]) * (w - w_arr[j]));
32 double dw = std::min({1.0e-5, w_arr[0] / 10, w_arr[
Nb - 1] / 1000});
33 double C0_Re = (
J(dw, w_arr, c_arr,
Nb) -
J(-dw, w_arr, c_arr,
Nb)) / (2 *
beta * dw);
34 for (
int i = 0; i < Nw; ++i) {
36 Cw[i] = (w[i] == 0) ? C0_Re :
J(w[i], w_arr, c_arr,
Nb) * (1 + 1 / (exp(
beta * w[i]) - 1.0f));
39 double sum = 0.0e0, tmp = 1.0e0, Cp, Cm;
40 double wp = w[i], wm = w[i];
42 while (std::abs(tmp) > 1.0e-6 || std::abs(tmp / sum) > 1.0e-8) {
43 wp += dw, wm -= dw, k++;
44 Cp = (wp == 0) ? C0_Re :
J(wp, w_arr, c_arr,
Nb) * (1 + 1 / (exp(
beta * wp) - 1.0f));
45 Cm = (wm == 0) ? C0_Re :
J(wm, w_arr, c_arr,
Nb) * (1 + 1 / (exp(
beta * wm) - 1.0f));
46 tmp = (Cp - Cm) / (
double) k;
64 case StrengthPolicy::Lambda: {
69 case StrengthPolicy::Alpha: {
70 double strength =
_param->get_double(
"strength",
LOC(), 1.0f);
74 case StrengthPolicy::Eta: {
79 case StrengthPolicy::Erg: {
86 beta = 1.0f / (phys::au::k * temperature);
93 case BathPolicy::Debye: {
94 for (
int j = 0; j <
Nb; ++j) {
100 case BathPolicy::Ohmic: {
101 for (
int j = 0; j <
Nb; ++j) {
107 case BathPolicy::Closure: {
110 case BathPolicy::ReadFormula: {
113 case BathPolicy::ReadFile:
116 std::string bath_readfile =
_param->get_string(
"bath_readfile",
LOC(),
"bath.spectrum");
117 std::ifstream ifs(bath_readfile);
119 std::string firstline, unit_str1, unit_str2, DIS_FLAG;
122 getline(ifs, firstline);
123 std::stringstream sstr(firstline);
124 sstr >> unit_str1 >> unit_str2;
136 for (
int j = 0; j <
Nb; ++j) {
138 if (DIS_FLAG ==
"WC") {
139 if (ifs >> val)
omegas[j] = val / w_unit;
140 if (ifs >> val)
coeffs[j] = val / pow(c_unit, 1.5e0);
141 }
else if (DIS_FLAG ==
"WS") {
142 if (ifs >> val)
omegas[j] = val / w_unit;
144 }
else if (DIS_FLAG ==
"WG") {
145 if (ifs >> val)
omegas[j] = val / w_unit;
149 }
catch (std::runtime_error& e) {
157 for (
int j = 0; j <
Nb; ++j) {
166 p_sigma[j] = std::sqrt(Qoverbeta);
std::shared_ptr< Param > _param
Shared pointer to the Param object associated with this kernel.
virtual int getType() const
Get the type of the kernel.
static int fun_Cw(kids_complex *Cw_arr, double *w, int Nw, double *w_arr, double *c_arr, double beta, int Nb)
StrengthPolicy::_type strength_type
BathPolicy::_type bath_type
virtual const std::string getName()
Get the name of the kernel.
virtual void setInputParam_impl(std::shared_ptr< Param > &PM)
Virtual function to set input parameters for the kernel implementation.
virtual void setInputDataSet_impl(std::shared_ptr< DataSet > &DS)
Virtual function to set input data set for the kernel implementation.
static double J(double w, double *w_arr=nullptr, double *c_arr=nullptr, int Nb=0)
static uval parse(const std::string &str)
CONSTEXPR_DECOR value_type conv(const uval &u)
#define LOC()
show the location information for debug
VARIABLE< kids_real > p_sigma
VARIABLE< kids_real > x_sigma
VARIABLE< kids_real > omegas
VARIABLE< kids_real > coeffs
< http://warp.povusers.org/FunctionParser/fparser.html
std::complex< double > kids_complex
Alias for complex number type.
constexpr real_precision halfpi
constexpr real_precision pi
pi
constexpr std::complex< real_precision > im(0.0L, 1.0L)
Imaginary Unit.
constexpr dimension7 temperature_d
constexpr dimension7 energy_d
[M*L^2/T^2] force integrate length
constexpr uint32_t hash(const char *str)
declaration of variables used in the program.