@@ -495,13 +495,14 @@ function TWeibullReionization_xe(this, z, tau, xe_recomb)
495
495
z_mid = this% redshift ! 50% ionized (set by tau solver)
496
496
497
497
! Weibull function: xe_frac = exp(-(z-z_late)^k / lambda^k)
498
+ ! This gives ionized fraction that decreases from 1 at z_late to 0 at high z
498
499
! where lambda and k are computed from the parameterization
499
500
if (z > z_late) then
500
501
z_norm = z - z_late
501
502
weibull_arg = (z_norm / this% weibull_lambda)** this% weibull_k
502
503
xe_frac = exp (- weibull_arg)
503
504
else
504
- xe_frac = 1._dl
505
+ xe_frac = 1._dl ! Fully ionized at z <= z_late
505
506
end if
506
507
507
508
TWeibullReionization_xe = xe_frac * (this% fraction - xstart) + xstart
@@ -528,7 +529,7 @@ end subroutine TWeibullReionization_get_timesteps
528
529
529
530
subroutine TWeibullReionization_SetParamsForZre (this )
530
531
class(TWeibullReionization) :: this
531
- real (dl) :: z_early, z_late, z_mid, delta_z
532
+ real (dl) :: z_early, z_late, z_mid, delta_z, A_z
532
533
533
534
! Calculate Weibull parameters following Trac et al. 2022 (ApJ 927, 186) Eqs. 10-15
534
535
! and arXiv:2505.15899v1 parameterization
@@ -539,36 +540,38 @@ subroutine TWeibullReionization_SetParamsForZre(this)
539
540
! - A_z: asymmetry parameter (reion_asymmetry)
540
541
!
541
542
! Following Trac et al. 2022 Eq. 10-11:
542
- ! Delta z = z_ear - z_lat
543
- ! A_z = (z_ear - z_lat ) / (z_mid - z_lat )
543
+ ! Delta z = z_early - z_late
544
+ ! A_z = (z_early - z_late ) / (z_mid - z_late )
544
545
545
546
z_late = this% reion_redshift_complete
546
547
z_early = z_late + this% reion_duration ! Delta z_90
547
548
z_mid = this% redshift
548
549
549
- ! Calculate Weibull parameters following the standard parameterization
550
+ ! Calculate Weibull parameters following the Trac et al. parameterization
550
551
! For the Weibull CDF: F(z) = 1 - exp(-((z-z_late)/lambda)^k)
551
552
! where F(z) is the ionized fraction
552
553
delta_z = z_early - z_late
553
- if (delta_z > 0._dl .and. this% reion_asymmetry > 0._dl ) then
554
- ! The asymmetry parameter A_z relates to the Weibull shape parameter k
555
- ! Following the standard approach: use A_z to determine the shape
554
+ if (delta_z > 0._dl .and. this% reion_asymmetry > 0._dl .and. z_mid > z_late) then
555
+ ! Calculate the actual asymmetry from the current parameters
556
+ A_z = delta_z / (z_mid - z_late)
557
+
558
+ ! Use the asymmetry parameter to determine the Weibull shape parameter k
559
+ ! Following Trac et al. approach: k is related to asymmetry
556
560
this% weibull_k = this% reion_asymmetry
557
561
558
562
! Calculate scale parameter lambda from the midpoint condition
559
563
! At z_mid, we want F = 0.5 (50% ionized)
560
564
! 0.5 = 1 - exp(-((z_mid-z_late)/lambda)^k)
561
- ! Solving: lambda = (z_mid - z_late) / (-ln(0.5))^(1/k)
562
- if (z_mid > z_late) then
563
- this% weibull_lambda = (z_mid - z_late) / (log (2._dl ))** (1._dl / this% weibull_k)
564
- else
565
- ! Fallback: use duration-based estimate
566
- this% weibull_lambda = delta_z / (2._dl * (log (2._dl ))** (1._dl / this% weibull_k))
567
- end if
565
+ ! Solving: lambda = (z_mid - z_late) / (ln(2))^(1/k)
566
+ this% weibull_lambda = (z_mid - z_late) / (log (2._dl ))** (1._dl / this% weibull_k)
568
567
else
569
568
! Fallback values for edge cases
570
569
this% weibull_k = 2._dl
571
- this% weibull_lambda = max (delta_z / 2._dl , 0.5_dl )
570
+ if (delta_z > 0._dl ) then
571
+ this% weibull_lambda = delta_z / (2._dl * (log (2._dl ))** (1._dl / this% weibull_k))
572
+ else
573
+ this% weibull_lambda = 0.5_dl
574
+ end if
572
575
end if
573
576
574
577
end subroutine TWeibullReionization_SetParamsForZre
0 commit comments