The following is my current work-around. For this case, I've inserted the output bits into the
insert_peak macro.
A default option to write all parameters with their corresponding errors would still be welcome.
-Peter
/*
Model-Free peak fitting of PDF data.
This version allows independent peak width parameterization.
Author: Peter C. Metz
Date: 07/14/2021 11:25 EDT
*/
' ----------------------- Macros -------------------------- {{{
macro MM(&v1, &v2) {min=v1; max=v2;}
macro baseline(rho0, rho0v)
{
#m_argu rho0 If_Prm_Eqn_Rpt(rho0, rho0v, min 1e-03)
fit_obj #m_unique baseline = - 4 Pi X CeV(rho0, rho0v) ;
Plot_Fit_Obj(1, baseline)
}
macro create_prm_file(filename)
{
out filename Out_String("")
}
macro insert_peak(ac, av, xoc, xov, wc, wv)
{
insert_peak(ac, av, xoc, xov, wc, wv,)
}
macro insert_peak(ac, av, xoc, xov, wc, wv, filename)
{
' the arguments
#m_argu ac If_Prm_Eqn_Rpt(ac, av, min 1e-06) ' amplitude av
#m_argu xoc If_Prm_Eqn_Rpt(xoc, xov, min = Max(X1, Val-.05); max = Min(X2, Val+.05); del = .3 Peak_Calculation_Step ;) ' position
#m_argu wc If_Prm_Eqn_Rpt(wc, wv, min 1e-06) ' width
' the peak
fit_obj #m_unique peak = CV(ac, av) Gauss(CV(xoc, xov), CV(wc,wv)) ;
Plot_Fit_Obj(1, peak)
' the output
#m_ifarg filename "" #m_else
out filename append
load out_record out_fmt out_eqn {
"%.6f " = CV(ac, av) ;
"%.6f " = Error(CV(ac, av)) ;
"%.6f " = CV(xoc, xov) ;
"%.6f " = Error(CV(xoc, xov)) ;
"%.6f " = CV(wc, wv) ;
"%.6f\n" = Error(CV(wc, wv)) ;
}
#m_endif
}
macro WriteFit(filename)
{
out filename
out_record out_fmt "# r Yobs Ycalc Ydiff\n"
xdd_out filename append
load out_record out_fmt out_eqn {
"%.6f " = X ;
"%.6f " = Yobs ;
"%.6f " = Ycalc ;
"%.6f\n" = Yobs - Ycalc ;
}
}
' --------------------------------------------------------- }}}
' ----------------------- Global -------------------------- {{{
prm !Qmax 25
prm rho0 0.03673 MM(1e-03, 0.25) ' average atomic number density (CeO2 ~ 0.07)
prm beq_Ce 0.21686 MM(1e-03, 1)
prm beq_O 0.15279 MM(1e-03, 1)
prm !beq_CeO = beq_Ce + beq_O ;: 0.36965
prm !beq_OO = 2 beq_O ;: 0.30558
prm !beq_CeCe = 2 beq_Ce ;: 0.43372
' --------------------------------------------------------- }}}
' ----------------------- Control ------------------------- {{{
Backup_INP
do_errors
macro DATA { ... }
num_runs 22
#list FileName {
...
}
macro filename { FileName(Run_Number) }
out_file = String(batch_fit_##Run_Number##_##filename##.inp);
'out_prm_vals_on_convergence PARAMETERS_##Run_Number##_##filename##.dat
macro OUT_PRM_FILE {PARAMETERS_##Run_Number##_##filename##.dat}
create_prm_file(##OUT_PRM_FILE##)
macro rmin {1.5}
macro rmax {5.0}
macro rstep {0.025}
' --------------------------------------------------------- }}}
' ----------------------- Main ---------------------------- {{{
xdd ##DATA##/##filename##.xy
r_wp 11.55308
pdf_data
start_X rmin
finish_X rmax
rebin_with_dx_of rstep
weighting = 1 ;
' G(r) baseline
baseline(, rho0)
' Peaks
macro pos_1 {@}
macro amp {@}
insert_peak(##amp##, 1, ##pos_1##, 2.34169`, , beq_CeO, ##OUT_PRM_FILE##) ' Ce-O 2.36748
insert_peak(##amp##, 1, ##pos_1##, 2.71514`, , beq_OO, ##OUT_PRM_FILE##) ' O-O 2.7337
insert_peak(##amp##, 1, ##pos_1##, 3.84038`, , beq_CeCe, ##OUT_PRM_FILE##) ' Ce-Ce, O-O 3.8667
insert_peak(##amp##, 1, ##pos_1##, 4.46623`, , beq_CeO, ##OUT_PRM_FILE##) ' Ce-O 4.5337
insert_peak(##amp##, 1, ##pos_1##, 4.72782`, , beq_OO, ##OUT_PRM_FILE##) ' O-O 4.73495
' output
WriteFit(FIT_##Run_Number##_##filename##.dat)
' --------------------------------------------------------- }}}