-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathYSWoodSaxon.cpp
82 lines (76 loc) · 2.65 KB
/
YSWoodSaxon.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//
// YSWoodSaxon.cpp
// The Wood Saxon function
//
// Created by Yves Schutz on 03/01/14.
// Copyright (c) 2014 Yves Schutz. All rights reserved.
//
#include <QDebug>
#include <QtMath>
#include "qcustomplot.h"
#include "YSWoodSaxon.h"
//______________________________________________________________________________
YSWoodSaxon::YSWoodSaxon() :
mType(kWS)
{
SetName("");
SetAxisLabel("Radius (fm)", "Density (/fm3)");
}
//______________________________________________________________________________
qreal YSWoodSaxon::Eval(qreal x) const
{
// compute the function at x
qreal rv = 0.;
switch (mType) {
case kWS: {
rv = mPar[0] * mPar[1] * ( 1 + mPar[2] * qPow(x / mPar[3], 2)) / (1 + qExp((x - mPar[3]) / mPar[4]));
break;
}
case kRWS: {
rv = x * x * (1 + mPar[2] * qPow(x / mPar[0], 2)) / (1 + qExp(( x - mPar[0]) / mPar[1]));
break;
}
default:
break;
}
return rv;
}
//______________________________________________________________________________
void YSWoodSaxon::Print() const
{
// print the formula
switch (mType) {
case kWS: {
qDebug() << "Wood Saxon formula for nuclear density radial distribution";
if (mNames.size() == mPar.size()) {
qDebug() << QString("%1 * %2 * ( 1 + %3 * power(x / %4, 2)) / (1+ exp(x - %4) / %5))").arg(mNames[0])
.arg(mNames[1]).arg(mNames[2]).arg(mNames[3]).arg(mNames[4]);
for(int index = 0; index < mPar.size(); index++)
qDebug() << QString("%1 = %2").arg(mNames[index]).arg(mPar[index]);
}
else {
qDebug() << QString("[0] * [1] * ( 1 + * [2] * power(x / [3], 2)) / (1+ exp(x - [3]) / [4]))");
for(int index = 0; index < mPar.size(); index++)
qDebug() << QString("[%1] = %2").arg(index).arg(mPar[index]);
}
break;
}
case kRWS: {
qDebug() << "R times Wood Saxon formula for nuclear density radial distribution";
if (mNames.size() == mPar.size()) {
qDebug() << QString("x * x * ( 1 + %3 * power(x / %1, 2)) / (1+ exp(x - %1) / %2))").arg(mNames[0])
.arg(mNames[1]).arg(mNames[2]);
for(int index = 0; index < mPar.size(); index++)
qDebug() << QString("%1 = %2").arg(mNames[index]).arg(mPar[index]);
}
else {
qDebug() << QString("x * x * ( 1 + * [2] * power(x / [0], 2)) / (1+ exp(x - [0]) / [1]))");
for(int index = 0; index < mPar.size(); index++)
qDebug() << QString("[%1] = %2").arg(index).arg(mPar[index]);
}
break;
}
default:
break;
}
}