EGSnrc C++ class library  Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
estar.h
Go to the documentation of this file.
1 /*
2 ###############################################################################
3 #
4 # EGSnrc estar
5 # Copyright (C) 2026 National Research Council Canada
6 #
7 # This file is part of EGSnrc.
8 #
9 # EGSnrc is free software: you can redistribute it and/or modify it under
10 # the terms of the GNU Affero General Public License as published by the
11 # Free Software Foundation, either version 3 of the License, or (at your
12 # option) any later version.
13 #
14 # EGSnrc is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 # FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
17 # more details.
18 #
19 # You should have received a copy of the GNU Affero General Public License
20 # along with EGSnrc. If not, see <http://www.gnu.org/licenses/>.
21 #
22 ###############################################################################
23 #
24 # Author: Sehmimul Hoque, 2022
25 #
26 # Contributors: Martin J. Berger
27 # Johnathan S. Coursey
28 # Reid Townson
29 # Ernesto Mainegra-Hing
30 #
31 # Based on the original ESTAR code by Martin J. Berger,
32 # National Institute of Standards and Technology (NIST). Including
33 # modifications by Johnathan S. Coursey.
34 #
35 ###############################################################################
36 */
37 
38 #pragma once
39 #include <string>
40 #include "estar_formulaCalcs.h"
41 #include "estar_dataParser.h"
42 
79 void outputDensityFile(float mediaDensity, double *densityCorr, double *enGrid,
80  float *meanIval, formula_calc fc, std::string outputFilename);
81 
82 
131 int estarCalculation(int isCompound, int NEP, float mediaDensity,
132  std::string *elementArray, double *massFraction,
133  float *numOfAtoms, double *densityCorr, double *enGrid,
134  float *meanIval, float *ipotval, int mediaNum,
135  std::string outputFilename);
136 
137 
144 struct bspol {
145  double density_corr;
147  int lb_index;
149  int ub_index;
151 };
152 
153 
174 bspol fbspol(double s, const std::vector<double> &x, const std::vector<double> &a,
175  const std::vector<double> &b, const std::vector<double> &c,
176  const std::vector<double> &d);
177 
178 
189 struct scof {
190  std::vector<double> a;
191  std::vector<double> b;
192  std::vector<double> c;
193  std::vector<double> d;
195  explicit scof(int n) : a(n), b(n), c(n), d(n) {}
196 };
197 
198 
213 scof fscof(int nmax, const vector<double> &x, const vector<double> &f);
214 
215 
235 double objective_function(double tau, const vector<double> &f,
236  const vector<double> &eps, int nmax, double x);
237 
238 
262 double bisec(double lowerbound, double upperbound, double tolerance,
263  double tau, const std::vector<double> &f,
264  const std::vector<double> &eps, int nmax);
bspol fbspol(double s, const std::vector< double > &x, const std::vector< double > &a, const std::vector< double > &b, const std::vector< double > &c, const std::vector< double > &d)
Evaluate the cubic spline interpolant at a given point.
Definition: estar.cpp:980
double objective_function(double tau, const vector< double > &f, const vector< double > &eps, int nmax, double x)
Objective function for the bisection solver.
Definition: estar.cpp:1119
scof fscof(int nmax, const vector< double > &x, const vector< double > &f)
Compute natural cubic spline coefficients.
Definition: estar.cpp:1062
int estarCalculation(int isCompound, int NEP, float mediaDensity, std::string *elementArray, double *massFraction, float *numOfAtoms, double *densityCorr, double *enGrid, float *meanIval, float *ipotval, int mediaNum, std::string outputFilename)
Compute density correction factors for a medium.
double bisec(double lowerbound, double upperbound, double tolerance, double tau, const std::vector< double > &f, const std::vector< double > &eps, int nmax)
Find the root of objective_function() by bisection.
void outputDensityFile(float mediaDensity, double *densityCorr, double *enGrid, float *meanIval, formula_calc fc, std::string outputFilename)
Output a density correction file.
Result struct returned by fbspol().
Definition: estar.h:144
double density_corr
Definition: estar.h:145
int lb_index
Definition: estar.h:147
int ub_index
Definition: estar.h:149
Spline coefficient struct returned by fscof().
Definition: estar.h:189
std::vector< double > d
Definition: estar.h:193
std::vector< double > a
Definition: estar.h:190
std::vector< double > c
Definition: estar.h:192
std::vector< double > b
Definition: estar.h:191