File indexing completed on 2025-01-31 09:22:00
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 #include "TLKModel.hh"
0031
0032 #include "ClassifiedDamage.hh"
0033 #include "Damage.hh"
0034 #include "DamageClassifier.hh"
0035 #include "ODESolver.hh"
0036 #include <cmath>
0037 #include <iostream>
0038 #include <fstream>
0039 #include <functional>
0040
0041
0042
0043 TLKModel::TLKModel(double pLambda1,double pLambda2, double pBeta1, double pBeta2,double pEta):
0044 fLambda1(pLambda1),
0045 fLambda2(pLambda2),
0046 fBeta1(pBeta1),
0047 fBeta2(pBeta2),
0048 fEta(pEta)
0049 {
0050 fSingleDSBYield = 0;
0051 fComplexDSBYield = 0;
0052 fBpForDSB = 10;
0053 fStartTime = 0.0;
0054 fStopTime = 480.0;
0055 fStepTime = 0.048;
0056 }
0057
0058
0059
0060 std::vector<double> TLKModel::TLK_odes_system(double t,std::vector<double> y){
0061
0062 std::vector<double> dxdt;
0063 double dxdt1 = -fLambda1*y[0]-fEta*y[0]*(y[0]+y[1]);
0064 double dxdt2 = -fLambda2*y[1]-fEta*y[1]*(y[0]+y[1]);
0065 double dxdt3 = fBeta1*fLambda1*y[0]+fBeta2*fLambda2*y[1]+0.25*fEta*(y[0]+y[1])*(y[0]+y[1]);
0066 dxdt.push_back(dxdt1);
0067 dxdt.push_back(dxdt2);
0068 dxdt.push_back(dxdt3);
0069 return dxdt;
0070 }
0071
0072
0073
0074 void TLKModel::ComputeAndSetDamageInput(std::vector<Damage> vecDamage)
0075 {
0076 DamageClassifier damClass;
0077 auto classifiedDamage = damClass.MakeCluster(vecDamage,fBpForDSB,false);
0078
0079 fComplexDSBYield = damClass.GetNumComplexDSB(classifiedDamage);
0080 fSingleDSBYield = damClass.GetNumDSB(classifiedDamage)-fComplexDSBYield;
0081
0082
0083 fComplexDSBYield = fComplexDSBYield/fDose;
0084 fSingleDSBYield = fSingleDSBYield/fDose;
0085
0086 }
0087
0088
0089
0090 double TLKModel::ComputeSF(double pDose)
0091 {
0092 std::vector<double> y( 3 );
0093
0094 y[0] = fSingleDSBYield*pDose;
0095 y[1] = fComplexDSBYield*pDose;
0096 y[2] = 0;
0097 std::function<std::vector<double>(double,std::vector<double>)>
0098 func = [this] (double t,std::vector<double> y) -> std::vector<double> {
0099 return TLK_odes_system(t,y);
0100 };
0101 ODESolver odeSolver;
0102 odeSolver.RungeKutta4(func,y,fStartTime,fStopTime,fStepTime);
0103 return std::exp(-y[2]);
0104 }
0105
0106
0107
0108 void TLKModel::CalculateRepair(double pDoseMax, double pDeltaDose)
0109 {
0110 fSFCurve.clear();
0111
0112 for(double dose=0.;dose<=pDoseMax;dose+=pDeltaDose)
0113 {
0114 fSFCurve.push_back(std::make_pair(dose,ComputeSF(dose)));
0115 }
0116
0117 }
0118
0119
0120
0121 void TLKModel::WriteOutput(std::string pFileName)
0122 {
0123 std::fstream file;
0124 file.open(pFileName.c_str(), std::ios_base::out);
0125
0126 file <<"#============================================= TLK MODEL =============================================#\n";
0127 file << " TLK Model, CalculateRepair with:\n";
0128 file << "#Single DSB = " << fSingleDSBYield << " (DSB/Gy) " << "#Complex DSB = " << fComplexDSBYield << " (DSB/Gy)\n";
0129 file << "#Lambda1 = " << fLambda1 << " " << "#Lambda2 = " << fLambda2 << "\n";
0130 file << "#Beta1 = " << fBeta1 << " " << "#Beta2 = " << fBeta2 << "\n";
0131 file << "#Eta = " << fEta << "\n";
0132 file <<"#========================================================================================================#\n";
0133
0134 file << "Dose (Gy)\tSF\n";
0135
0136 for(int i=0;i<fSFCurve.size();i++)
0137 {
0138 file << fSFCurve[i].first << "\t" << fSFCurve[i].second << "\n";
0139 }
0140
0141 file.close();
0142 }
0143
0144