Commit 0aa84331 authored by Berrill, Mark's avatar Berrill, Mark
Browse files

Updating miniapp

parent 67162480
Loading
Loading
Loading
Loading
+19 −13
Original line number Diff line number Diff line
@@ -8,7 +8,9 @@
static auto &perr = std::cerr;


// Subroutine to perform linear interpolation
/********************************************************
 * Linear interpolation                                  *
 ********************************************************/
double interp::interp_linear( size_t N, const double *xi, const double *yi, double x )
{
    size_t i = findfirstsingle( xi, N, x );
@@ -23,9 +25,6 @@ double interp::interp_linear( size_t N, const double *xi, const double *yi, doub
    double y   = dx2 * yi[i - 1] + dx * yi[i];
    return y;
}


// Subroutine to perform bi-linear interpolation using the full grid
double interp::bilinear( double x, double y, size_t N, size_t M, const double *xgrid,
    const double *ygrid, const double *f_grid )
{
@@ -56,9 +55,6 @@ double interp::bilinear( double x, double y, size_t N, size_t M, const double *x
    f   = ( dx * f2 + dx2 * f1 ) * dy2 + ( dx * f4 + dx2 * f3 ) * dy;
    return ( f );
}


// Subroutine to perform tri-linear interpolation using the full grid
double interp::trilinear( double x, double y, double z, size_t Nx, size_t Ny, size_t Nz,
    const double *xgrid, const double *ygrid, const double *zgrid, const double *f_grid )
{
@@ -96,7 +92,9 @@ double interp::trilinear( double x, double y, double z, size_t Nx, size_t Ny, si
}


// Subroutine to perform cubic hermite interpolation
/********************************************************
 * Cubic hermite interpolation                           *
 ********************************************************/
template<class TYPE>
static inline TYPE pchip( size_t N, size_t i, const TYPE *xi, const TYPE *yi, TYPE x )
{
@@ -158,7 +156,10 @@ float interp::interp_pchip( size_t N, const float *xi, const float *yi, float x
}


// This function calculates the FWHM by finding the narrowest region that contains 76% of the energy
/********************************************************
 * Calculate the FWHM by finding the narrowest region    *
 * that contains 76% of the energy                       *
 ********************************************************/
double interp::calc_width( size_t n, const double *x, const double *y )
{
    // Check the inputs
@@ -206,7 +207,9 @@ double interp::calc_width( size_t n, const double *x, const double *y )
}


// Get the 2 points on either side of a sign change
/********************************************************
 * Get the 2 points on either side of a sign change      *
 ********************************************************/
static inline void getPoints( size_t N, const double *x_in, const double *r_in,
    std::array<double, 4> &x, std::array<double, 4> &f, std::array<double, 2> &range )
{
@@ -254,8 +257,9 @@ static inline void getPoints( size_t N, const double *x_in, const double *r_in,
    range[1] = x[2];
}


// Calculate coefficients for the bisection method
/********************************************************
 * Calculate coefficients for the bisection method       *
 ********************************************************/
double interp::bisection_coeff(
    size_t N, const double *x_in, const double *r_in, std::array<double, 2> &range )
{
@@ -323,7 +327,9 @@ double interp::bisection_coeff(
}


// Modified bisection root finding
/********************************************************
 * Modified bisection root finding                       *
 ********************************************************/
double interp::bisection(
    std::function<double( double )> fun, double lb, double ub, double tol1, double tol2, int *N )
{
+155 −128

File changed.

Preview size limit exceeded, changes collapsed.

+306 −191

File changed.

Preview size limit exceeded, changes collapsed.

+3 −22

File changed.

Preview size limit exceeded, changes collapsed.

+1 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ namespace RayTrace {
 * @details  This function calculates the near and far field beam images.  This function is
 * thread-safe provided unique arrays for mem, image, I_ang are provided in the info struct.
 * @param info          Data structure containing the information needed to create the EUV beam
 * @param method        Method to use
 * images
 */
void create_image( create_image_struct *info, std::string method = "auto" );
Loading