Skip to content

Commit 9c2a9c7

Browse files
Converting from R in geom.py to R*R in geom.c
1 parent f62a167 commit 9c2a9c7

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

‎python/kdsource/geom.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -512,16 +512,16 @@ def __init__(
512512
"""
513513
super().__init__([1, 2, 3], ["rho", "psi"], ["cm", "deg"], "deg.cm")
514514
self.z = z
515-
self.rho_min = rho_min**2
516-
self.rho_max = rho_max**2
515+
self.rho_min = rho_min
516+
self.rho_max = rho_max
517517
self.psi_min = psi_min
518518
self.psi_max = psi_max
519519

520520
def transform(self, poss):
521521
"""
522522
Transform volume position (x,y,z) to circular flat position (rho,psi).
523523
"""
524-
rhos = np.sqrt(poss[:, 0]**2 + poss[:, 1]**2)**2
524+
rhos = np.sqrt(poss[:, 0]**2 + poss[:, 1]**2)
525525
psis = np.arctan2(poss[:, 1], poss[:, 0]) * 180 / np.pi
526526
return np.stack((rhos, psis), axis=1)
527527

@@ -531,8 +531,8 @@ def inverse_transform(self, poss):
531531
to volume position (x,y,z).
532532
"""
533533
z_col = np.broadcast_to(self.z, (*poss.shape[:-1], 1))
534-
x_col = poss[:, 0]**0.5 * np.cos(poss[:, 1] * np.pi / 180)
535-
y_col = poss[:, 0]**0.5 * np.sin(poss[:, 1] * np.pi / 180)
534+
x_col = poss[:, 0] * np.cos(poss[:, 1] * np.pi / 180)
535+
y_col = poss[:, 0] * np.sin(poss[:, 1] * np.pi / 180)
536536
return np.stack((x_col, y_col, z_col), axis=1)
537537

538538
def save(self, mtree):

‎src/kdsource/geom.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,9 @@ int SurfCirc_perturb(const Metric* metric, mcpl_particle_t* part, double bw, cha
201201
double psi_min=metric->params[2], psi_max=metric->params[3];
202202
double rho, psi, rho2, psi2;
203203

204+
rho_min *= rho_min;
205+
rho_max *= rho_max;
206+
204207
rho = part->position[0]*part->position[0]+part->position[1]*part->position[1];
205208
psi = atan2(part->position[1], part->position[0]);
206209

0 commit comments

Comments
 (0)