sync: upload 02_galaxy_dynamics to Hugging Face dataset
Browse files
02_galaxy_dynamics/clusters/d10_gauge_test.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Is the first-order expansion parameter gauge-dependent?
|
| 2 |
+
Same source, same mu, same r500 evaluation. Only the zero-point of Phi differs:
|
| 3 |
+
A: Phi(r_max)=0 (repo's aest_mu2_correction.py)
|
| 4 |
+
B: Phi(0)=0 (forward integration, as in an ODE solve)
|
| 5 |
+
W = W0 - mu^2 INT_0^r r'^2 Phi(r') dr' depends on that choice because Phi enters the source.
|
| 6 |
+
"""
|
| 7 |
+
import math, numpy as np, importlib.util
|
| 8 |
+
spec=importlib.util.spec_from_file_location("cm","cluster_mond_test.py")
|
| 9 |
+
cm=importlib.util.module_from_spec(spec); spec.loader.exec_module(cm)
|
| 10 |
+
MPC,G,MS,A0 = cm.MPC_M, cm.G_SI, cm.MSUN, cm.A0
|
| 11 |
+
H0i = cm.H0_KMS/cm.C_KMS
|
| 12 |
+
K2 = 3*H0i**2*cm.OM_M/(4*0.1**2*1.23e-8)
|
| 13 |
+
MU = math.sqrt(2*K2/(2-0.1))*0.1/MPC
|
| 14 |
+
RCF, N = 0.1, 4000
|
| 15 |
+
|
| 16 |
+
def run(gauge):
|
| 17 |
+
boosts, r_mu2 = [], []
|
| 18 |
+
for k,c in cm.load().items():
|
| 19 |
+
M500=c['M500']*1e14*MS; fbar=c['fgas']+0.015
|
| 20 |
+
r500=cm.r_delta(M500,c['z']); rc=RCF*r500
|
| 21 |
+
norm=fbar*M500/((r500/rc)-math.atan(r500/rc))
|
| 22 |
+
r=np.linspace(1e-4*r500, r500, N)
|
| 23 |
+
Menc=norm*((r/rc)-np.arctan(r/rc))
|
| 24 |
+
uE=G*Menc/r**2
|
| 25 |
+
g=uE+np.sqrt(uE*A0)
|
| 26 |
+
dr=np.gradient(r)[0]
|
| 27 |
+
if gauge=='A': Phi=-np.flip(np.cumsum(np.flip(g)*dr))
|
| 28 |
+
else: Phi=-np.cumsum(g*dr)
|
| 29 |
+
corr=-MU**2*np.cumsum(r**2*Phi)*dr
|
| 30 |
+
W0=G*Menc; W=W0+corr
|
| 31 |
+
boosts.append(W[-1]/W0[-1])
|
| 32 |
+
uE1=max(W[-1],0)/r[-1]**2
|
| 33 |
+
g1=uE1+math.sqrt(uE1*A0)
|
| 34 |
+
r_mu2.append(M500/(g1*r[-1]**2/G))
|
| 35 |
+
md=lambda a:(lambda s:(s[len(s)//2] if len(s)%2 else .5*(s[len(s)//2-1]+s[len(s)//2])))(sorted(a))
|
| 36 |
+
return md(boosts), md(r_mu2), boosts
|
| 37 |
+
|
| 38 |
+
for gname,label in [('A','Phi(r_max)=0 [repo]'),('B','Phi(0)=0 [ODE]')]:
|
| 39 |
+
med_b, med_R, bl = run(gname)
|
| 40 |
+
print(f"{label}: median W/W0 = {med_b:.2f} -> expansion param = {med_b-1:.2f} median R(+mu^2) = {med_R:.2f}")
|
| 41 |
+
print("\nper-cluster W/W0 (A vs B):")
|
| 42 |
+
bA=run('A')[2]; bB=run('B')[2]
|
| 43 |
+
names=list(cm.load().keys())
|
| 44 |
+
for n,a,b in list(zip(names,bA,bB))[:6]:
|
| 45 |
+
print(f" {n:<20} A={a:.2f} B={b:.2f}")
|
02_galaxy_dynamics/clusters/d10_nonlinear/d10_results.json
ADDED
|
@@ -0,0 +1,330 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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 0.7401164085163165,
|
| 6 |
+
"first_order_expansion_param_median": 1.6851915716276287,
|
| 7 |
+
"nonlin_caseA_pure_median_R500": 0.8440157293160513,
|
| 8 |
+
"nonlin_caseA_interp_median_R500": 0.5594557411904866,
|
| 9 |
+
"nonlin_caseA_pure_median_R054": 1.696401526716846,
|
| 10 |
+
"nonlin_caseA_interp_median_R054": 1.093909813081208,
|
| 11 |
+
"nonlin_caseB_pure_median_R054": 2.172895417964413,
|
| 12 |
+
"nonlin_caseB_interp_median_R054": 1.7617253675217133,
|
| 13 |
+
"nonlin_caseB_pure_median_R500": 4.36399361133773,
|
| 14 |
+
"nonlin_caseB_interp_median_R500": -5.451655761183373
|
| 15 |
+
},
|
| 16 |
+
"clusters": [
|
| 17 |
+
{
|
| 18 |
+
"cluster": "RX-J1347.5-1145",
|
| 19 |
+
"z": 0.451,
|
| 20 |
+
"M500": 22.2,
|
| 21 |
+
"fgas": 0.1,
|
| 22 |
+
"r500": 1.71,
|
| 23 |
+
"R_pure_MOND": 2.86,
|
| 24 |
+
"1st_order": {
|
| 25 |
+
"R_pure": 0.9707505013057578,
|
| 26 |
+
"R_interp": 0.793339474287864,
|
| 27 |
+
"W_W0": 3.4706042054013517,
|
| 28 |
+
"exp_param": 2.4706042054013517
|
| 29 |
+
},
|
| 30 |
+
"caseA_rmax_r500": {
|
| 31 |
+
"R_500_pure": 0.8279128364190905,
|
| 32 |
+
"R_054_pure": 1.770111956099933,
|
| 33 |
+
"R_500_interp": 0.4423692540450169,
|
| 34 |
+
"R_054_interp": 0.968639181509034
|
| 35 |
+
},
|
| 36 |
+
"caseB_rmax_r054": {
|
| 37 |
+
"R_500_pure": -34.49288726650135,
|
| 38 |
+
"R_054_pure": 2.715860459481268,
|
| 39 |
+
"R_500_interp": -16.317345578212965,
|
| 40 |
+
"R_054_interp": 2.0079628117989774
|
| 41 |
+
}
|
| 42 |
+
},
|
| 43 |
+
{
|
| 44 |
+
"cluster": "ABELL-1763",
|
| 45 |
+
"z": 0.228,
|
| 46 |
+
"M500": 16.01,
|
| 47 |
+
"fgas": 0.212,
|
| 48 |
+
"r500": 1.67,
|
| 49 |
+
"R_pure_MOND": 1.75,
|
| 50 |
+
"1st_order": {
|
| 51 |
+
"R_pure": 0.5880545109173597,
|
| 52 |
+
"R_interp": 0.4701255815265439,
|
| 53 |
+
"W_W0": 3.1872156810678947,
|
| 54 |
+
"exp_param": 2.1872156810678947
|
| 55 |
+
},
|
| 56 |
+
"caseA_rmax_r500": {
|
| 57 |
+
"R_500_pure": 0.5481365293686038,
|
| 58 |
+
"R_054_pure": 1.1060321765587668,
|
| 59 |
+
"R_500_interp": 0.2964676600049919,
|
| 60 |
+
"R_054_interp": 0.6126800678840837
|
| 61 |
+
},
|
| 62 |
+
"caseB_rmax_r054": {
|
| 63 |
+
"R_500_pure": null,
|
| 64 |
+
"R_054_pure": null,
|
| 65 |
+
"R_500_interp": null,
|
| 66 |
+
"R_054_interp": null
|
| 67 |
+
}
|
| 68 |
+
},
|
| 69 |
+
{
|
| 70 |
+
"cluster": "CL-J1226.9+3332",
|
| 71 |
+
"z": 0.89,
|
| 72 |
+
"M500": 15.3,
|
| 73 |
+
"fgas": 0.04,
|
| 74 |
+
"r500": 1.27,
|
| 75 |
+
"R_pure_MOND": 4.7,
|
| 76 |
+
"1st_order": {
|
| 77 |
+
"R_pure": 2.1213832744210888,
|
| 78 |
+
"R_interp": 1.8252661475881258,
|
| 79 |
+
"W_W0": 2.521046519986113,
|
| 80 |
+
"exp_param": 1.521046519986113
|
| 81 |
+
},
|
| 82 |
+
"caseA_rmax_r500": {
|
| 83 |
+
"R_500_pure": 2.0938504390824746,
|
| 84 |
+
"R_054_pure": 4.1609276947605425,
|
| 85 |
+
"R_500_interp": 1.562180887404737,
|
| 86 |
+
"R_054_interp": 3.0568510340967854
|
| 87 |
+
},
|
| 88 |
+
"caseB_rmax_r054": {
|
| 89 |
+
"R_500_pure": 9.871575899223101,
|
| 90 |
+
"R_054_pure": 5.236582557972768,
|
| 91 |
+
"R_500_interp": 17.79696930572127,
|
| 92 |
+
"R_054_interp": 4.212367037826679
|
| 93 |
+
}
|
| 94 |
+
},
|
| 95 |
+
{
|
| 96 |
+
"cluster": "ABELL-1689",
|
| 97 |
+
"z": 0.183,
|
| 98 |
+
"M500": 15.03,
|
| 99 |
+
"fgas": 0.156,
|
| 100 |
+
"r500": 1.67,
|
| 101 |
+
"R_pure_MOND": 1.98,
|
| 102 |
+
"1st_order": {
|
| 103 |
+
"R_pure": 0.6828339537227937,
|
| 104 |
+
"R_interp": 0.5575456573591017,
|
| 105 |
+
"W_W0": 3.3315281887018395,
|
| 106 |
+
"exp_param": 2.3315281887018395
|
| 107 |
+
},
|
| 108 |
+
"caseA_rmax_r500": {
|
| 109 |
+
"R_500_pure": 0.6031614251379042,
|
| 110 |
+
"R_054_pure": 1.2664573269776873,
|
| 111 |
+
"R_500_interp": 0.335312694869477,
|
| 112 |
+
"R_054_interp": 0.7183669019100052
|
| 113 |
+
},
|
| 114 |
+
"caseB_rmax_r054": {
|
| 115 |
+
"R_500_pure": -34.459598367167075,
|
| 116 |
+
"R_054_pure": 1.8788757496869901,
|
| 117 |
+
"R_500_interp": -13.534542426554173,
|
| 118 |
+
"R_054_interp": 1.3904740758277807
|
| 119 |
+
}
|
| 120 |
+
},
|
| 121 |
+
{
|
| 122 |
+
"cluster": "MACS-J0717.5+3745",
|
| 123 |
+
"z": 0.548,
|
| 124 |
+
"M500": 14.84,
|
| 125 |
+
"fgas": 0.17,
|
| 126 |
+
"r500": 1.44,
|
| 127 |
+
"R_pure_MOND": 2.16,
|
| 128 |
+
"1st_order": {
|
| 129 |
+
"R_pure": 0.8323029439867491,
|
| 130 |
+
"R_interp": 0.6738871066978505,
|
| 131 |
+
"W_W0": 2.6217497826197715,
|
| 132 |
+
"exp_param": 1.6217497826197715
|
| 133 |
+
},
|
| 134 |
+
"caseA_rmax_r500": {
|
| 135 |
+
"R_500_pure": 0.8570355425591039,
|
| 136 |
+
"R_054_pure": 1.6117915698857792,
|
| 137 |
+
"R_500_interp": 0.554166859486538,
|
| 138 |
+
"R_054_interp": 1.037537805918624
|
| 139 |
+
},
|
| 140 |
+
"caseB_rmax_r054": {
|
| 141 |
+
"R_500_pure": null,
|
| 142 |
+
"R_054_pure": null,
|
| 143 |
+
"R_500_interp": null,
|
| 144 |
+
"R_054_interp": null
|
| 145 |
+
}
|
| 146 |
+
},
|
| 147 |
+
{
|
| 148 |
+
"cluster": "ABELL-773",
|
| 149 |
+
"z": 0.217,
|
| 150 |
+
"M500": 10.14,
|
| 151 |
+
"fgas": 0.116,
|
| 152 |
+
"r500": 1.44,
|
| 153 |
+
"R_pure_MOND": 2.17,
|
| 154 |
+
"1st_order": {
|
| 155 |
+
"R_pure": 0.8782970814353347,
|
| 156 |
+
"R_interp": 0.7411715131570416,
|
| 157 |
+
"W_W0": 2.8680627054694403,
|
| 158 |
+
"exp_param": 1.8680627054694403
|
| 159 |
+
},
|
| 160 |
+
"caseA_rmax_r500": {
|
| 161 |
+
"R_500_pure": 0.8309959160729986,
|
| 162 |
+
"R_054_pure": 1.6981638711980707,
|
| 163 |
+
"R_500_interp": 0.564744622894435,
|
| 164 |
+
"R_054_interp": 1.1502818202437919
|
| 165 |
+
},
|
| 166 |
+
"caseB_rmax_r054": {
|
| 167 |
+
"R_500_pure": 13.684866752421263,
|
| 168 |
+
"R_054_pure": 2.282459761413679,
|
| 169 |
+
"R_500_interp": -50.278612498299324,
|
| 170 |
+
"R_054_interp": 1.7824960891274104
|
| 171 |
+
}
|
| 172 |
+
},
|
| 173 |
+
{
|
| 174 |
+
"cluster": "ABELL-209",
|
| 175 |
+
"z": 0.206,
|
| 176 |
+
"M500": 9.61,
|
| 177 |
+
"fgas": 0.146,
|
| 178 |
+
"r500": 1.42,
|
| 179 |
+
"R_pure_MOND": 1.92,
|
| 180 |
+
"1st_order": {
|
| 181 |
+
"R_pure": 0.7805501004078574,
|
| 182 |
+
"R_interp": 0.6531203044618311,
|
| 183 |
+
"W_W0": 2.748633360635486,
|
| 184 |
+
"exp_param": 1.7486333606354858
|
| 185 |
+
},
|
| 186 |
+
"caseA_rmax_r500": {
|
| 187 |
+
"R_500_pure": 0.7617531304065059,
|
| 188 |
+
"R_054_pure": 1.515533388417638,
|
| 189 |
+
"R_500_interp": 0.5178476871494215,
|
| 190 |
+
"R_054_interp": 1.0246347023679832
|
| 191 |
+
},
|
| 192 |
+
"caseB_rmax_r054": {
|
| 193 |
+
"R_500_pure": 5.352679158141293,
|
| 194 |
+
"R_054_pure": 1.9859418395549069,
|
| 195 |
+
"R_500_interp": -105.47718374091156,
|
| 196 |
+
"R_054_interp": 1.5339328224274906
|
| 197 |
+
}
|
| 198 |
+
},
|
| 199 |
+
{
|
| 200 |
+
"cluster": "ABELL-2142",
|
| 201 |
+
"z": 0.091,
|
| 202 |
+
"M500": 8.78,
|
| 203 |
+
"fgas": 0.158,
|
| 204 |
+
"r500": 1.44,
|
| 205 |
+
"R_pure_MOND": 1.76,
|
| 206 |
+
"1st_order": {
|
| 207 |
+
"R_pure": 0.703955415631539,
|
| 208 |
+
"R_interp": 0.5898511259772057,
|
| 209 |
+
"W_W0": 2.8155951311491343,
|
| 210 |
+
"exp_param": 1.8155951311491343
|
| 211 |
+
},
|
| 212 |
+
"caseA_rmax_r500": {
|
| 213 |
+
"R_500_pure": 0.6775612416047615,
|
| 214 |
+
"R_054_pure": 1.3633933413933081,
|
| 215 |
+
"R_500_interp": 0.4567624070914522,
|
| 216 |
+
"R_054_interp": 0.9158168262234765
|
| 217 |
+
},
|
| 218 |
+
"caseB_rmax_r054": {
|
| 219 |
+
"R_500_pure": 6.277115941327805,
|
| 220 |
+
"R_054_pure": 1.8112508283099582,
|
| 221 |
+
"R_500_interp": -54.382059863637494,
|
| 222 |
+
"R_054_interp": 1.4009256524376275
|
| 223 |
+
}
|
| 224 |
+
},
|
| 225 |
+
{
|
| 226 |
+
"cluster": "RXC-J0532.9-3701",
|
| 227 |
+
"z": 0.275,
|
| 228 |
+
"M500": 6.55,
|
| 229 |
+
"fgas": 0.141,
|
| 230 |
+
"r500": 1.22,
|
| 231 |
+
"R_pure_MOND": 1.89,
|
| 232 |
+
"1st_order": {
|
| 233 |
+
"R_pure": 0.8684123360205743,
|
| 234 |
+
"R_interp": 0.7390613038755914,
|
| 235 |
+
"W_W0": 2.3211109548258113,
|
| 236 |
+
"exp_param": 1.3211109548258113
|
| 237 |
+
},
|
| 238 |
+
"caseA_rmax_r500": {
|
| 239 |
+
"R_500_pure": 0.8923344189481345,
|
| 240 |
+
"R_054_pure": 1.6946391822356215,
|
| 241 |
+
"R_500_interp": 0.6685784556904835,
|
| 242 |
+
"R_054_interp": 1.2427822505988633
|
| 243 |
+
},
|
| 244 |
+
"caseB_rmax_r054": {
|
| 245 |
+
"R_500_pure": 2.8908683790519065,
|
| 246 |
+
"R_054_pure": 2.0530452852263914,
|
| 247 |
+
"R_500_interp": 3.5036888605733223,
|
| 248 |
+
"R_054_interp": 1.6277988254327505
|
| 249 |
+
}
|
| 250 |
+
},
|
| 251 |
+
{
|
| 252 |
+
"cluster": "ABELL-383",
|
| 253 |
+
"z": 0.187,
|
| 254 |
+
"M500": 5.87,
|
| 255 |
+
"fgas": 0.121,
|
| 256 |
+
"r500": 1.22,
|
| 257 |
+
"R_pure_MOND": 1.93,
|
| 258 |
+
"1st_order": {
|
| 259 |
+
"R_pure": 0.8955974398032021,
|
| 260 |
+
"R_interp": 0.7715984885985148,
|
| 261 |
+
"W_W0": 2.394798948079102,
|
| 262 |
+
"exp_param": 1.394798948079102
|
| 263 |
+
},
|
| 264 |
+
"caseA_rmax_r500": {
|
| 265 |
+
"R_500_pure": 0.9001480135330979,
|
| 266 |
+
"R_054_pure": 1.756691909532218,
|
| 267 |
+
"R_500_interp": 0.6836082896915057,
|
| 268 |
+
"R_054_interp": 1.3087174975506024
|
| 269 |
+
},
|
| 270 |
+
"caseB_rmax_r054": {
|
| 271 |
+
"R_500_pure": 3.375308064534166,
|
| 272 |
+
"R_054_pure": 2.160164746629698,
|
| 273 |
+
"R_500_interp": 4.474897860165818,
|
| 274 |
+
"R_054_interp": 1.741576299428902
|
| 275 |
+
}
|
| 276 |
+
},
|
| 277 |
+
{
|
| 278 |
+
"cluster": "ABELL-2034",
|
| 279 |
+
"z": 0.113,
|
| 280 |
+
"M500": 5.17,
|
| 281 |
+
"fgas": 0.073,
|
| 282 |
+
"r500": 1.2,
|
| 283 |
+
"R_pure_MOND": 2.31,
|
| 284 |
+
"1st_order": {
|
| 285 |
+
"R_pure": 1.099870361032015,
|
| 286 |
+
"R_interp": 0.9710907798182495,
|
| 287 |
+
"W_W0": 2.535470393935551,
|
| 288 |
+
"exp_param": 1.535470393935551
|
| 289 |
+
},
|
| 290 |
+
"caseA_rmax_r500": {
|
| 291 |
+
"R_500_pure": 1.0550425489747668,
|
| 292 |
+
"R_054_pure": 2.1701215780680396,
|
| 293 |
+
"R_500_interp": 0.8271231900447641,
|
| 294 |
+
"R_054_interp": 1.6747238194959893
|
| 295 |
+
},
|
| 296 |
+
"caseB_rmax_r054": {
|
| 297 |
+
"R_500_pure": 6.160178311651659,
|
| 298 |
+
"R_054_pure": 2.7479289294293836,
|
| 299 |
+
"R_500_interp": 20.93915470822127,
|
| 300 |
+
"R_054_interp": 2.2919899491078115
|
| 301 |
+
}
|
| 302 |
+
},
|
| 303 |
+
{
|
| 304 |
+
"cluster": "RXC-J0232.2-4420",
|
| 305 |
+
"z": 0.284,
|
| 306 |
+
"M500": 4.44,
|
| 307 |
+
"fgas": 0.123,
|
| 308 |
+
"r500": 1.07,
|
| 309 |
+
"R_pure_MOND": 1.89,
|
| 310 |
+
"1st_order": {
|
| 311 |
+
"R_pure": 0.9674068553306222,
|
| 312 |
+
"R_interp": 0.840106132057202,
|
| 313 |
+
"W_W0": 2.073442161021012,
|
| 314 |
+
"exp_param": 1.073442161021012
|
| 315 |
+
},
|
| 316 |
+
"caseA_rmax_r500": {
|
| 317 |
+
"R_500_pure": 1.0051624516979714,
|
| 318 |
+
"R_054_pure": 1.8779458801139,
|
| 319 |
+
"R_500_interp": 0.8008402923403947,
|
| 320 |
+
"R_054_interp": 1.4531334184354536
|
| 321 |
+
},
|
| 322 |
+
"caseB_rmax_r054": {
|
| 323 |
+
"R_500_pure": 2.486089156133088,
|
| 324 |
+
"R_054_pure": 2.185626089299128,
|
| 325 |
+
"R_500_interp": 2.6312309041874267,
|
| 326 |
+
"R_054_interp": 1.7818744356145249
|
| 327 |
+
}
|
| 328 |
+
}
|
| 329 |
+
]
|
| 330 |
+
}
|
02_galaxy_dynamics/clusters/d10_nonlinear/d10_solve.py
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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9 |
+
Mpc = 3.085677581e22 # m
|
| 10 |
+
a0 = 1.0557e-10 # m s^-2
|
| 11 |
+
mu = 1.0 / (0.9895 * Mpc)# m^-1 (~3.272e-23 m^-1)
|
| 12 |
+
|
| 13 |
+
# 12-Cluster Sample Data from TARGET_D10_CLUSTERS.md Table
|
| 14 |
+
clusters = [
|
| 15 |
+
{'name': 'RX-J1347.5-1145', 'z': 0.451, 'M500': 22.20, 'fgas': 0.100, 'r500': 1.71, 'R_pure_MOND': 2.86},
|
| 16 |
+
{'name': 'ABELL-1763', 'z': 0.228, 'M500': 16.01, 'fgas': 0.212, 'r500': 1.67, 'R_pure_MOND': 1.75},
|
| 17 |
+
{'name': 'CL-J1226.9+3332', 'z': 0.890, 'M500': 15.30, 'fgas': 0.040, 'r500': 1.27, 'R_pure_MOND': 4.70},
|
| 18 |
+
{'name': 'ABELL-1689', 'z': 0.183, 'M500': 15.03, 'fgas': 0.156, 'r500': 1.67, 'R_pure_MOND': 1.98},
|
| 19 |
+
{'name': 'MACS-J0717.5+3745','z': 0.548, 'M500': 14.84, 'fgas': 0.170, 'r500': 1.44, 'R_pure_MOND': 2.16},
|
| 20 |
+
{'name': 'ABELL-773', 'z': 0.217, 'M500': 10.14, 'fgas': 0.116, 'r500': 1.44, 'R_pure_MOND': 2.17},
|
| 21 |
+
{'name': 'ABELL-209', 'z': 0.206, 'M500': 9.61, 'fgas': 0.146, 'r500': 1.42, 'R_pure_MOND': 1.92},
|
| 22 |
+
{'name': 'ABELL-2142', 'z': 0.091, 'M500': 8.78, 'fgas': 0.158, 'r500': 1.44, 'R_pure_MOND': 1.76},
|
| 23 |
+
{'name': 'RXC-J0532.9-3701','z': 0.275, 'M500': 6.55, 'fgas': 0.141, 'r500': 1.22, 'R_pure_MOND': 1.89},
|
| 24 |
+
{'name': 'ABELL-383', 'z': 0.187, 'M500': 5.87, 'fgas': 0.121, 'r500': 1.22, 'R_pure_MOND': 1.93},
|
| 25 |
+
{'name': 'ABELL-2034', 'z': 0.113, 'M500': 5.17, 'fgas': 0.073, 'r500': 1.20, 'R_pure_MOND': 2.31},
|
| 26 |
+
{'name': 'RXC-J0232.2-4420','z': 0.284, 'M500': 4.44, 'fgas': 0.123, 'r500': 1.07, 'R_pure_MOND': 1.89},
|
| 27 |
+
]
|
| 28 |
+
|
| 29 |
+
# Response functions v(uE)
|
| 30 |
+
def v_pure_mond(uE):
|
| 31 |
+
uE_safe = np.maximum(uE, 0.0)
|
| 32 |
+
return np.sqrt(a0 * uE_safe)
|
| 33 |
+
|
| 34 |
+
def v_full_interp(uE):
|
| 35 |
+
uE_safe = np.maximum(uE, 0.0)
|
| 36 |
+
return (uE_safe + np.sqrt(uE_safe**2 + 4.0 * a0 * uE_safe)) / 2.0
|
| 37 |
+
|
| 38 |
+
# 1) First-Order Perturbative Expansion Calculation
|
| 39 |
+
def compute_first_order_expansion(c):
|
| 40 |
+
M500_kg = c['M500'] * 1e14 * M_sun
|
| 41 |
+
r500_m = c['r500'] * Mpc
|
| 42 |
+
fbary = c['fgas'] + 0.015
|
| 43 |
+
Mbary_kg = fbary * M500_kg
|
| 44 |
+
W0 = G * Mbary_kg
|
| 45 |
+
r_min = 1e-4 * Mpc
|
| 46 |
+
|
| 47 |
+
# Analytical unperturbed MOND potential with Phi(r500) = 0
|
| 48 |
+
# Phi_0(r) = -G Mbary / r - sqrt(a0 G Mbary) * ln(r500_m / r)
|
| 49 |
+
# W1(r500) = W0 - mu^2 \int_{r_min}^{r500} r'^2 Phi_0(r') dr'
|
| 50 |
+
# \int_{r_min}^{r500} (-G Mbary r' - sqrt(a0 G Mbary) r'^2 ln(r500/r')) dr'
|
| 51 |
+
# \int r'^2 ln(r500/r') dr' = [r'^3/3 ln(r500/r') + r'^3/9]_{r_min}^{r500} = r500^3 / 9
|
| 52 |
+
term1 = -G * Mbary_kg * (r500_m**2 - r_min**2) / 2.0
|
| 53 |
+
term2 = -np.sqrt(a0 * G * Mbary_kg) * (r500_m**3 / 9.0)
|
| 54 |
+
integral_phi = term1 + term2
|
| 55 |
+
|
| 56 |
+
W1_500 = W0 - mu**2 * integral_phi
|
| 57 |
+
exp_param = (W1_500 / W0) - 1.0 # W1/W0 - 1
|
| 58 |
+
|
| 59 |
+
# Effective acceleration at r500
|
| 60 |
+
uE_500 = W1_500 / r500_m**2
|
| 61 |
+
|
| 62 |
+
# Pure MOND branch
|
| 63 |
+
v_pure = np.sqrt(a0 * uE_500)
|
| 64 |
+
g_pure = uE_500 + v_pure
|
| 65 |
+
Mdyn_pure = g_pure * r500_m**2 / G
|
| 66 |
+
R_pure_1st = M500_kg / Mdyn_pure
|
| 67 |
+
|
| 68 |
+
# Full Interp branch
|
| 69 |
+
v_interp = (uE_500 + np.sqrt(uE_500**2 + 4.0 * a0 * uE_500)) / 2.0
|
| 70 |
+
g_interp = uE_500 + v_interp
|
| 71 |
+
Mdyn_interp = g_interp * r500_m**2 / G
|
| 72 |
+
R_interp_1st = M500_kg / Mdyn_interp
|
| 73 |
+
|
| 74 |
+
return {
|
| 75 |
+
'R_pure_1st': R_pure_1st,
|
| 76 |
+
'R_interp_1st': R_interp_1st,
|
| 77 |
+
'W_W0_ratio': W1_500 / W0,
|
| 78 |
+
'exp_param': exp_param
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
# 2) Full Non-linear BVP Shooting Solver
|
| 82 |
+
def solve_nonlinear_bvp(c, v_func, r_max_factor):
|
| 83 |
+
M500_kg = c['M500'] * 1e14 * M_sun
|
| 84 |
+
r500_m = c['r500'] * Mpc
|
| 85 |
+
r_max_m = r_max_factor * r500_m
|
| 86 |
+
fbary = c['fgas'] + 0.015
|
| 87 |
+
Mbary_kg = fbary * M500_kg
|
| 88 |
+
W0 = G * Mbary_kg
|
| 89 |
+
r_min = 1e-4 * Mpc
|
| 90 |
+
|
| 91 |
+
def odes(r, y):
|
| 92 |
+
Phi, W = y[0], y[1]
|
| 93 |
+
uE = W / (r**2)
|
| 94 |
+
v_val = float(v_func(np.array([uE]))[0])
|
| 95 |
+
dPhi_dr = uE + v_val
|
| 96 |
+
dW_dr = - mu**2 * (r**2) * Phi
|
| 97 |
+
return [dPhi_dr, dW_dr]
|
| 98 |
+
|
| 99 |
+
def shoot_err(p):
|
| 100 |
+
sol = solve_ivp(odes, (r_min, r_max_m), [p, W0], method='RK45', rtol=1e-8, atol=1e-10)
|
| 101 |
+
if sol.status != 0:
|
| 102 |
+
return 1e15
|
| 103 |
+
return sol.y[0, -1]
|
| 104 |
+
|
| 105 |
+
# Bracket search around analytical guess
|
| 106 |
+
p_center = -G * Mbary_kg / r_min - np.sqrt(a0 * G * Mbary_kg) * np.log(r_max_m / r_min)
|
| 107 |
+
ps = np.linspace(p_center * 5.0, p_center * 0.05, 300)
|
| 108 |
+
errs = [shoot_err(p) for p in ps]
|
| 109 |
+
|
| 110 |
+
root_p = None
|
| 111 |
+
for i in range(len(ps)-1):
|
| 112 |
+
if errs[i] * errs[i+1] <= 0 and abs(errs[i]) < 1e14 and abs(errs[i+1]) < 1e14:
|
| 113 |
+
try:
|
| 114 |
+
root_p = brentq(shoot_err, ps[i], ps[i+1])
|
| 115 |
+
break
|
| 116 |
+
except Exception:
|
| 117 |
+
pass
|
| 118 |
+
|
| 119 |
+
if root_p is None:
|
| 120 |
+
return None
|
| 121 |
+
|
| 122 |
+
# Detailed integration out to max(r500_m, r_max_m)
|
| 123 |
+
r_eval_max = max(r500_m, r_max_m)
|
| 124 |
+
sol = solve_ivp(odes, (r_min, r_eval_max), [root_p, W0], method='DOP853', rtol=1e-10, atol=1e-12, dense_output=True)
|
| 125 |
+
|
| 126 |
+
# Evaluate at r500
|
| 127 |
+
y_500 = sol.sol(r500_m)
|
| 128 |
+
Phi_500, W_500 = y_500[0], y_500[1]
|
| 129 |
+
uE_500 = W_500 / (r500_m**2)
|
| 130 |
+
v_500 = float(v_func(np.array([uE_500]))[0])
|
| 131 |
+
g_500 = uE_500 + v_500
|
| 132 |
+
Mdyn_500 = g_500 * (r500_m**2) / G
|
| 133 |
+
R_500 = M500_kg / Mdyn_500
|
| 134 |
+
|
| 135 |
+
# Evaluate at 0.54 r500
|
| 136 |
+
r_054 = 0.54 * r500_m
|
| 137 |
+
y_054 = sol.sol(r_054)
|
| 138 |
+
Phi_054, W_054 = y_054[0], y_054[1]
|
| 139 |
+
uE_054 = W_054 / (r_054**2)
|
| 140 |
+
v_054 = float(v_func(np.array([uE_054]))[0])
|
| 141 |
+
g_054 = uE_054 + v_054
|
| 142 |
+
Mdyn_054 = g_054 * (r_054**2) / G
|
| 143 |
+
R_054 = M500_kg / Mdyn_054
|
| 144 |
+
|
| 145 |
+
return {
|
| 146 |
+
'root_p': root_p,
|
| 147 |
+
'R_500': R_500,
|
| 148 |
+
'W_500_ratio': W_500 / W0,
|
| 149 |
+
'Mdyn_500_1014': Mdyn_500 / (1e14 * M_sun),
|
| 150 |
+
'R_054': R_054,
|
| 151 |
+
'W_054_ratio': W_054 / W0,
|
| 152 |
+
'Mdyn_054_1014': Mdyn_054 / (1e14 * M_sun)
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
# Run execution
|
| 156 |
+
print("=== RUNNING FULL D10 HELMHOLTZ CLUSTER SOLVER ===")
|
| 157 |
+
|
| 158 |
+
results_summary = []
|
| 159 |
+
|
| 160 |
+
for c in clusters:
|
| 161 |
+
exp_res = compute_first_order_expansion(c)
|
| 162 |
+
caseA_pure = solve_nonlinear_bvp(c, v_pure_mond, r_max_factor=1.0)
|
| 163 |
+
caseA_interp = solve_nonlinear_bvp(c, v_full_interp, r_max_factor=1.0)
|
| 164 |
+
caseB_pure = solve_nonlinear_bvp(c, v_pure_mond, r_max_factor=0.54)
|
| 165 |
+
caseB_interp = solve_nonlinear_bvp(c, v_full_interp, r_max_factor=0.54)
|
| 166 |
+
|
| 167 |
+
results_summary.append({
|
| 168 |
+
'cluster': c['name'],
|
| 169 |
+
'z': c['z'],
|
| 170 |
+
'M500': c['M500'],
|
| 171 |
+
'fgas': c['fgas'],
|
| 172 |
+
'r500': c['r500'],
|
| 173 |
+
'R_pure_MOND': c['R_pure_MOND'],
|
| 174 |
+
'1st_order': {
|
| 175 |
+
'R_pure': exp_res['R_pure_1st'],
|
| 176 |
+
'R_interp': exp_res['R_interp_1st'],
|
| 177 |
+
'W_W0': exp_res['W_W0_ratio'],
|
| 178 |
+
'exp_param': exp_res['exp_param']
|
| 179 |
+
},
|
| 180 |
+
'caseA_rmax_r500': {
|
| 181 |
+
'R_500_pure': caseA_pure['R_500'] if caseA_pure else None,
|
| 182 |
+
'R_054_pure': caseA_pure['R_054'] if caseA_pure else None,
|
| 183 |
+
'R_500_interp': caseA_interp['R_500'] if caseA_interp else None,
|
| 184 |
+
'R_054_interp': caseA_interp['R_054'] if caseA_interp else None,
|
| 185 |
+
},
|
| 186 |
+
'caseB_rmax_r054': {
|
| 187 |
+
'R_500_pure': caseB_pure['R_500'] if caseB_pure else None,
|
| 188 |
+
'R_054_pure': caseB_pure['R_054'] if caseB_pure else None,
|
| 189 |
+
'R_500_interp': caseB_interp['R_500'] if caseB_interp else None,
|
| 190 |
+
'R_054_interp': caseB_interp['R_054'] if caseB_interp else None,
|
| 191 |
+
}
|
| 192 |
+
})
|
| 193 |
+
|
| 194 |
+
# Print Full Comparison Table
|
| 195 |
+
print("\nTABLE: 12-Cluster Comparison Across Solves")
|
| 196 |
+
print(f"{'Cluster':18s} | {'Pure MOND':10s} | {'1st-Ord Pure':12s} | {'1st-Ord Interp':14s} | {'Full Nonlin (r500)':18s} | {'Full Nonlin (0.54r500)':20s}")
|
| 197 |
+
print(f"{'':18s} | {'R_500':10s} | {'R_500':12s} | {'R_500':14s} | {'R_500 (p/i)':18s} | {'R_054 (p/i)':20s}")
|
| 198 |
+
print("-" * 105)
|
| 199 |
+
|
| 200 |
+
for r in results_summary:
|
| 201 |
+
p_mond = f"{r['R_pure_MOND']:10.2f}"
|
| 202 |
+
o1_p = f"{r['1st_order']['R_pure']:12.2f}"
|
| 203 |
+
o1_i = f"{r['1st_order']['R_interp']:14.2f}"
|
| 204 |
+
|
| 205 |
+
cA_p = r['caseA_rmax_r500']['R_500_pure']
|
| 206 |
+
cA_i = r['caseA_rmax_r500']['R_500_interp']
|
| 207 |
+
cA_str = f"{cA_p:.2f} / {cA_i:.2f}" if cA_p and cA_i else "FAILED"
|
| 208 |
+
|
| 209 |
+
cB_p = r['caseB_rmax_r054']['R_054_pure']
|
| 210 |
+
cB_i = r['caseB_rmax_r054']['R_054_interp']
|
| 211 |
+
cB_str = f"{cB_p:.2f} / {cB_i:.2f}" if cB_p and cB_i else "FAILED"
|
| 212 |
+
|
| 213 |
+
print(f"{r['cluster']:18s} | {p_mond} | {o1_p} | {o1_i} | {cA_str:18s} | {cB_str:20s}")
|
| 214 |
+
|
| 215 |
+
# Compute Medians and Means
|
| 216 |
+
pure_mond_list = [r['R_pure_MOND'] for r in results_summary]
|
| 217 |
+
o1_pure_list = [r['1st_order']['R_pure'] for r in results_summary]
|
| 218 |
+
o1_interp_list = [r['1st_order']['R_interp'] for r in results_summary]
|
| 219 |
+
exp_param_list = [r['1st_order']['exp_param'] for r in results_summary]
|
| 220 |
+
|
| 221 |
+
cA_500_pure_list = [r['caseA_rmax_r500']['R_500_pure'] for r in results_summary if r['caseA_rmax_r500']['R_500_pure'] is not None]
|
| 222 |
+
cA_500_interp_list = [r['caseA_rmax_r500']['R_500_interp'] for r in results_summary if r['caseA_rmax_r500']['R_500_interp'] is not None]
|
| 223 |
+
cA_054_pure_list = [r['caseA_rmax_r500']['R_054_pure'] for r in results_summary if r['caseA_rmax_r500']['R_054_pure'] is not None]
|
| 224 |
+
cA_054_interp_list = [r['caseA_rmax_r500']['R_054_interp'] for r in results_summary if r['caseA_rmax_r500']['R_054_interp'] is not None]
|
| 225 |
+
|
| 226 |
+
cB_500_pure_list = [r['caseB_rmax_r054']['R_500_pure'] for r in results_summary if r['caseB_rmax_r054']['R_500_pure'] is not None]
|
| 227 |
+
cB_500_interp_list = [r['caseB_rmax_r054']['R_500_interp'] for r in results_summary if r['caseB_rmax_r054']['R_500_interp'] is not None]
|
| 228 |
+
cB_054_pure_list = [r['caseB_rmax_r054']['R_054_pure'] for r in results_summary if r['caseB_rmax_r054']['R_054_pure'] is not None]
|
| 229 |
+
cB_054_interp_list = [r['caseB_rmax_r054']['R_054_interp'] for r in results_summary if r['caseB_rmax_r054']['R_054_interp'] is not None]
|
| 230 |
+
|
| 231 |
+
print("-" * 105)
|
| 232 |
+
print(f"{'MEDIAN':18s} | {np.median(pure_mond_list):10.2f} | {np.median(o1_pure_list):12.2f} | {np.median(o1_interp_list):14.2f} | {np.median(cA_500_pure_list):.2f} / {np.median(cA_500_interp_list):.2f} | {np.median(cB_054_pure_list):.2f} / {np.median(cB_054_interp_list):.2f}")
|
| 233 |
+
print(f"{'MEAN':18s} | {np.mean(pure_mond_list):10.2f} | {np.mean(o1_pure_list):12.2f} | {np.mean(o1_interp_list):14.2f} | {np.mean(cA_500_pure_list):.2f} / {np.mean(cA_500_interp_list):.2f} | {np.mean(cB_054_pure_list):.2f} / {np.mean(cB_054_interp_list):.2f}")
|
| 234 |
+
print(f"Median First-Order Expansion Parameter (W/W0 - 1) = {np.median(exp_param_list):.2f}")
|
| 235 |
+
|
| 236 |
+
# Save JSON results to shared workspace
|
| 237 |
+
with open('d10_results.json', 'w') as f:
|
| 238 |
+
json.dump({
|
| 239 |
+
'summary': {
|
| 240 |
+
'pure_mond_median_R500': float(np.median(pure_mond_list)),
|
| 241 |
+
'first_order_pure_median_R500': float(np.median(o1_pure_list)),
|
| 242 |
+
'first_order_interp_median_R500': float(np.median(o1_interp_list)),
|
| 243 |
+
'first_order_expansion_param_median': float(np.median(exp_param_list)),
|
| 244 |
+
'nonlin_caseA_pure_median_R500': float(np.median(cA_500_pure_list)),
|
| 245 |
+
'nonlin_caseA_interp_median_R500': float(np.median(cA_500_interp_list)),
|
| 246 |
+
'nonlin_caseA_pure_median_R054': float(np.median(cA_054_pure_list)),
|
| 247 |
+
'nonlin_caseA_interp_median_R054': float(np.median(cA_054_interp_list)),
|
| 248 |
+
'nonlin_caseB_pure_median_R054': float(np.median(cB_054_pure_list)),
|
| 249 |
+
'nonlin_caseB_interp_median_R054': float(np.median(cB_054_interp_list)),
|
| 250 |
+
'nonlin_caseB_pure_median_R500': float(np.median(cB_500_pure_list)),
|
| 251 |
+
'nonlin_caseB_interp_median_R500': float(np.median(cB_500_interp_list)),
|
| 252 |
+
},
|
| 253 |
+
'clusters': results_summary
|
| 254 |
+
}, f, indent=2)
|
| 255 |
+
|
| 256 |
+
print("\nResults saved to d10_results.json")
|
02_galaxy_dynamics/clusters/d10_nonlinear/d10_verify.py
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
+
from scipy.integrate import solve_ivp
|
| 3 |
+
from scipy.optimize import brentq
|
| 4 |
+
|
| 5 |
+
# Constants
|
| 6 |
+
G = 6.67430e-11 # m^3 kg^-1 s^-2
|
| 7 |
+
M_sun = 1.9884e30 # kg
|
| 8 |
+
Mpc = 3.085677581e22 # m
|
| 9 |
+
a0 = 1.0557e-10 # m/s^2
|
| 10 |
+
mu = 1.0 / (0.9895 * Mpc) # m^-1
|
| 11 |
+
|
| 12 |
+
# 12 Clusters data from TARGET_D10_CLUSTERS.md
|
| 13 |
+
clusters = [
|
| 14 |
+
{'name': 'RX-J1347.5-1145', 'z': 0.451, 'M500': 22.20, 'fgas': 0.100, 'r500': 1.71, 'R_std': 2.86},
|
| 15 |
+
{'name': 'ABELL-1763', 'z': 0.228, 'M500': 16.01, 'fgas': 0.212, 'r500': 1.67, 'R_std': 1.75},
|
| 16 |
+
{'name': 'CL-J1226.9+3332', 'z': 0.890, 'M500': 15.30, 'fgas': 0.040, 'r500': 1.27, 'R_std': 4.70},
|
| 17 |
+
{'name': 'ABELL-1689', 'z': 0.183, 'M500': 15.03, 'fgas': 0.156, 'r500': 1.67, 'R_std': 1.98},
|
| 18 |
+
{'name': 'MACS-J0717.5+3745', 'z': 0.548, 'M500': 14.84, 'fgas': 0.170, 'r500': 1.44, 'R_std': 2.16},
|
| 19 |
+
{'name': 'ABELL-773', 'z': 0.217, 'M500': 10.14, 'fgas': 0.116, 'r500': 1.44, 'R_std': 2.17},
|
| 20 |
+
{'name': 'ABELL-209', 'z': 0.206, 'M500': 9.61, 'fgas': 0.146, 'r500': 1.42, 'R_std': 1.92},
|
| 21 |
+
{'name': 'ABELL-2142', 'z': 0.091, 'M500': 8.78, 'fgas': 0.158, 'r500': 1.44, 'R_std': 1.76},
|
| 22 |
+
{'name': 'RXC-J0532.9-3701', 'z': 0.275, 'M500': 6.55, 'fgas': 0.141, 'r500': 1.22, 'R_std': 1.89},
|
| 23 |
+
{'name': 'ABELL-383', 'z': 0.187, 'M500': 5.87, 'fgas': 0.121, 'r500': 1.22, 'R_std': 1.93},
|
| 24 |
+
{'name': 'ABELL-2034', 'z': 0.113, 'M500': 5.17, 'fgas': 0.073, 'r500': 1.20, 'R_std': 2.31},
|
| 25 |
+
{'name': 'RXC-J0232.2-4420', 'z': 0.284, 'M500': 4.44, 'fgas': 0.123, 'r500': 1.07, 'R_std': 1.89},
|
| 26 |
+
]
|
| 27 |
+
|
| 28 |
+
def v_pure_mond(uE):
|
| 29 |
+
return np.where(uE >= 0, np.sqrt(a0 * uE), -np.sqrt(a0 * np.abs(uE)))
|
| 30 |
+
|
| 31 |
+
def v_full_interp(uE):
|
| 32 |
+
# uE = v^2 / (a0 + v)
|
| 33 |
+
res = np.zeros_like(uE)
|
| 34 |
+
pos = uE >= 0
|
| 35 |
+
res[pos] = (uE[pos] + np.sqrt(uE[pos]**2 + 4 * a0 * uE[pos])) / 2.0
|
| 36 |
+
neg = ~pos
|
| 37 |
+
res[neg] = (uE[neg] - np.sqrt(uE[neg]**2 - 4 * a0 * uE[neg])) / 2.0
|
| 38 |
+
return res
|
| 39 |
+
|
| 40 |
+
def solve_cluster(c, v_func, r_max_factor=1.0):
|
| 41 |
+
M500_kg = c['M500'] * 1e14 * M_sun
|
| 42 |
+
r500_m = c['r500'] * Mpc
|
| 43 |
+
r_max_m = r_max_factor * r500_m
|
| 44 |
+
|
| 45 |
+
fbary = c['fgas'] + 0.015
|
| 46 |
+
Mbary_kg = fbary * M500_kg
|
| 47 |
+
W0 = G * Mbary_kg
|
| 48 |
+
r_min = 1e-4 * Mpc
|
| 49 |
+
|
| 50 |
+
def odes(r, y):
|
| 51 |
+
Phi = y[0]
|
| 52 |
+
W = y[1]
|
| 53 |
+
uE = W / r**2
|
| 54 |
+
if isinstance(uE, np.ndarray):
|
| 55 |
+
v_val = v_func(uE)
|
| 56 |
+
else:
|
| 57 |
+
v_val = float(v_func(np.array([uE]))[0])
|
| 58 |
+
dPhi_dr = uE + v_val
|
| 59 |
+
dW_dr = - mu**2 * r**2 * Phi
|
| 60 |
+
return [dPhi_dr, dW_dr]
|
| 61 |
+
|
| 62 |
+
def shoot_err(p):
|
| 63 |
+
sol = solve_ivp(odes, (r_min, r_max_m), [p, W0], method='RK45', rtol=1e-8, atol=1e-10)
|
| 64 |
+
return sol.y[0, -1]
|
| 65 |
+
|
| 66 |
+
# Search for root p in a wide interval
|
| 67 |
+
# Estimate p range
|
| 68 |
+
p_center = -G * Mbary_kg / r_min - np.sqrt(a0 * G * Mbary_kg) * np.log(r_max_m / r_min)
|
| 69 |
+
p_min = p_center * 3.0
|
| 70 |
+
p_max = p_center * 0.1
|
| 71 |
+
|
| 72 |
+
# Grid search for sign change
|
| 73 |
+
ps = np.linspace(p_min, p_max, 100)
|
| 74 |
+
errs = [shoot_err(p) for p in ps]
|
| 75 |
+
|
| 76 |
+
root_p = None
|
| 77 |
+
for i in range(len(ps)-1):
|
| 78 |
+
if errs[i] * errs[i+1] <= 0:
|
| 79 |
+
root_p = brentq(shoot_err, ps[i], ps[i+1])
|
| 80 |
+
break
|
| 81 |
+
|
| 82 |
+
if root_p is None:
|
| 83 |
+
return None
|
| 84 |
+
|
| 85 |
+
sol = solve_ivp(odes, (r_min, r_max_m), [root_p, W0], method='RK45', rtol=1e-10, atol=1e-12, dense_output=True)
|
| 86 |
+
|
| 87 |
+
# Evaluate at r500
|
| 88 |
+
y_500 = sol.sol(r500_m)
|
| 89 |
+
Phi_500, W_500 = y_500[0], y_500[1]
|
| 90 |
+
uE_500 = W_500 / r500_m**2
|
| 91 |
+
v_500 = float(v_func(np.array([uE_500]))[0])
|
| 92 |
+
g_500 = uE_500 + v_500
|
| 93 |
+
Mdyn_500 = g_500 * r500_m**2 / G
|
| 94 |
+
R_500 = M500_kg / Mdyn_500
|
| 95 |
+
|
| 96 |
+
# Evaluate at 0.54 r500
|
| 97 |
+
r_054 = 0.54 * r500_m
|
| 98 |
+
y_054 = sol.sol(r_054)
|
| 99 |
+
Phi_054, W_054 = y_054[0], y_054[1]
|
| 100 |
+
uE_054 = W_054 / r_054**2
|
| 101 |
+
v_054 = float(v_func(np.array([uE_054]))[0])
|
| 102 |
+
g_054 = uE_054 + v_054
|
| 103 |
+
Mdyn_054 = g_054 * r_054**2 / G
|
| 104 |
+
|
| 105 |
+
# In lensing, what is enclosed weak lensing mass M_lens(0.54 r500)?
|
| 106 |
+
# For a NFW/point/cluster profile, enclosed mass at 0.54 r500:
|
| 107 |
+
# If we assume lensing profile follows same spatial scaling or point mass:
|
| 108 |
+
# Under point mass assumption: M_lens(0.54 r500) = M500
|
| 109 |
+
# Under NFW (c=3-4), M(0.54 r500) / M500 is ~0.60-0.65.
|
| 110 |
+
R_054_point = M500_kg / Mdyn_054
|
| 111 |
+
|
| 112 |
+
return {
|
| 113 |
+
'R_500': R_500,
|
| 114 |
+
'W_500_ratio': W_500 / W0,
|
| 115 |
+
'Mdyn_500': Mdyn_500 / (1e14 * M_sun),
|
| 116 |
+
'R_054_point': R_054_point,
|
| 117 |
+
'W_054_ratio': W_054 / W0,
|
| 118 |
+
'Mdyn_054': Mdyn_054 / (1e14 * M_sun)
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
print("Running full non-linear solves for all 12 clusters...")
|
| 122 |
+
print("1) Pure MOND branch with boundary Phi(r500) = 0:")
|
| 123 |
+
print(f"{'Cluster':18s} | {'R_std':6s} | {'R_500':6s} | {'W/W0(r500)':9s} | {'R_054':6s} | {'W/W0(0.54)':9s}")
|
| 124 |
+
print("-" * 65)
|
| 125 |
+
|
| 126 |
+
r500_results_pure = []
|
| 127 |
+
r054_results_pure = []
|
| 128 |
+
|
| 129 |
+
for c in clusters:
|
| 130 |
+
res = solve_cluster(c, v_pure_mond, r_max_factor=1.0)
|
| 131 |
+
if res:
|
| 132 |
+
r500_results_pure.append(res['R_500'])
|
| 133 |
+
r054_results_pure.append(res['R_054_point'])
|
| 134 |
+
print(f"{c['name']:18s} | {c['R_std']:6.2f} | {res['R_500']:6.2f} | {res['W_500_ratio']:9.2f} | {res['R_054_point']:6.2f} | {res['W_054_ratio']:9.2f}")
|
| 135 |
+
else:
|
| 136 |
+
print(f"{c['name']:18s} | {c['R_std']:6.2f} | FAILED")
|
| 137 |
+
|
| 138 |
+
print(f"Median R_500 (pure MOND branch) = {np.median(r500_results_pure):.2f}")
|
| 139 |
+
print(f"Mean R_500 (pure MOND branch) = {np.mean(r500_results_pure):.2f}")
|
| 140 |
+
|
| 141 |
+
print("\n2) Full interpolation branch with boundary Phi(r500) = 0:")
|
| 142 |
+
print(f"{'Cluster':18s} | {'R_std':6s} | {'R_500':6s} | {'W/W0(r500)':9s} | {'R_054':6s} | {'W/W0(0.54)':9s}")
|
| 143 |
+
print("-" * 65)
|
| 144 |
+
|
| 145 |
+
r500_results_full = []
|
| 146 |
+
r054_results_full = []
|
| 147 |
+
|
| 148 |
+
for c in clusters:
|
| 149 |
+
res = solve_cluster(c, v_full_interp, r_max_factor=1.0)
|
| 150 |
+
if res:
|
| 151 |
+
r500_results_full.append(res['R_500'])
|
| 152 |
+
r054_results_full.append(res['R_054_point'])
|
| 153 |
+
print(f"{c['name']:18s} | {c['R_std']:6.2f} | {res['R_500']:6.2f} | {res['W_500_ratio']:9.2f} | {res['R_054_point']:6.2f} | {res['W_054_ratio']:9.2f}")
|
| 154 |
+
else:
|
| 155 |
+
print(f"{c['name']:18s} | {c['R_std']:6.2f} | FAILED")
|
| 156 |
+
|
| 157 |
+
print(f"Median R_500 (full interp branch) = {np.median(r500_results_full):.2f}")
|
| 158 |
+
print(f"Mean R_500 (full interp branch) = {np.mean(r500_results_full):.2f}")
|