Hello TOPAS users,
I have been trying to implement this function for the transmission coefficient for a flat plate sample in my refinement:

I have written the macro in a PrivateUserMacro.inc file which I am including in my input file. When I try and run the input file with my I get: "Uninitialized_Variable in equation: d". I have also tried adding my macro to Topas.inc, but I still getting the same error.
What am I doing wrong here to implement the macro? Is there any guide somewhere on how to write macros in TOPAS that I am missing?
Thank you for your help in advance,
Jesper
Here is the macro I wrote (practically a copy of Absorption_With_Sample_Thickness_mm_Shape_Intensity with a new equation):
macro AbsorptionTest(u, uv, d, dv)
{
#m_argu u
#m_argu d
#m_ifarg u ""
#m_unique_not_refine u
#m_endif
scale_pks = (1 - ((2 Cos(2 Th) (Exp(-CeV(u, uv) CeV(d, dv)) - Exp(-CeV(u, uv) CeV(d, dv) / Cos(2 Th)))) / (1 - Cos(2 Th))));
}
and my input file:
'-------------------------------------------------------------------------------
'Jesper Simonsen 01/2025
'Single frame refinement of NIST SRM 660c (LaB6) a = 4.156826 +/- 0.00008 Å
'Setup for DanMAX 2025
'-------------------------------------------------------------------------------
#include O:\Nat_Uorg\MCH\StudentFolders\JesperSimonsen\TOPAS\inps\PrivateUserMacros.inc
r_wp 8.32412739 r_exp 17.4962779 r_p 6.0467918
r_wp_dash 11.0881092 r_p_dash 9.83301832 r_exp_dash 23.3058231
weighted_Durbin_Watson 1.31575213 gof 0.475765614
iters 1000
continue_after_convergence
do_errors
macro data_directory {O:\Nat_Uorg\MCH\DATA_beamtimes\2024_06_MAXIV_DanMAX\calibrants\xy}
macro file_stem {NIST_SRM660c_T492um_Om0_1640}
macro suffix {.xy}
macro file_dets(data_directory, file_stem, suffix) {data_directory##file_stem##suffix}
macro file {file_dets(data_directory, file_stem, suffix)}
macro ResultsName {##file_stem##_Results.txt}
xdd file
x_calculation_step = Yobs_dx_at(Xo);
start_X 4.5
finish_X 23.5
'Background Chebyshev
prm bkg0 14.3535687_0.073959209
prm bkg1 -8.38130791
0.125189758
prm bkg2 4.86044004_0.115148926
prm bkg3 -2.79583381
0.0930832915
prm bkg4 1.27888351`_0.0884453891
prm !bkg5 0
prm !bkg6 0
prm !bkg7 0
prm !bkg8 0
prm !bkg9 0
prm !bkg10 0
prm !bkg11 0
bkg =bkg0; =bkg1; =bkg2; =bkg3; =bkg4; =bkg5; =bkg6; =bkg7; =bkg8; =bkg9; =bkg10; =bkg11;
prm !wavlen 0.3542449 'Calculated based on wavelength, from PONI: 0.35424490084445085 Å
lam ymin_on_ymax 0.0001 la 1 lo =wavlen; lh 0.0001
Rs 423.28 'Sample to detector distance, from PONI: 0.42327769500162377 m
LP_Factor_Synchrotron_Simple ' Uses the Lorentz_Factor macro, 1 / (Sin(Th)^2 Cos(Th)))
AbsorptionTest(!u, 20, !d, 0.0492)
Zero_Error(zero, 9.80015643e-06`_9.48525348e-05)
str
phase_name "LaB6"
space_group 221
Cubic(!lpa 4.156826) '4.156826
site La x 0.000 y 0.000 z 0.000 occ La 1 beq bLa 0.52122`_0.02172
site B x 0.198 y 0.500 z 0.500 occ B 1 beq bB 0.07688`_0.13702
scale scale 9.79058328e-06`_5.049e-08
r_bragg 2.0933997
TCHZ_Peak_Type(
!pku, 0,
pkv, 0.0103738026`_0.000448607496,
pkw,-0.00408608128`_4.95131523e-05,
!pkz, 0,
!pky, 0,
!pkx, 0
)
Phase_Density_g_on_cm3( 4.71093703)