Skip to content

Commit 2558dcc

Browse files
committed
update to prints, more numba, todos and further bug discoveries
1 parent 86e364b commit 2558dcc

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

CCA.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ def CCA_subcluster(R: np.ndarray, N: int, DF: float, kf: float,iter: int,N_subcl
2020

2121
PCA_OK, data, n_clusters, i_orden = PCA_subcluster(N, N_subcluster, R, DF, kf, tolerance)
2222

23+
print("==============================")
24+
print(" PCA DONE! ")
25+
print("==============================")
2326
if not PCA_OK:
2427
return CCA_OK, PCA_OK
2528

PCA.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import numpy as np
2+
import numba
23
import time
34

45
def PCA(number: int, mass: np.ndarray, r: np.ndarray, Df: float, kf: float, tolerance: float) -> tuple[bool, np.ndarray]:
@@ -89,6 +90,7 @@ def PCA(number: int, mass: np.ndarray, r: np.ndarray, Df: float, kf: float, tole
8990
m1 = m3
9091
rg1 = (np.exp(np.sum(np.log(r))/np.log(r).size))*(np.power(n1/kf, 1/Df))
9192
k = k + 1
93+
# FIXME: this gets stuck for some reason (no apparent connection to the arcos issue)
9294

9395
data_new = np.zeros((number,4))
9496
for i in range(number):
@@ -179,6 +181,7 @@ def gamma_calc(rg1: float,rg2: float,rg3: float,n1: int,n2: int,n3: int) -> tupl
179181

180182
return gamma_ok, gamma_pc
181183

184+
@numba.njit()
182185
def random_list_selection(gamma_ok: bool, gamma_pc: float,X: np.ndarray, Y: np.ndarray, Z: np.ndarray,R: np.ndarray, n1: int, x_cm: float, y_cm: float, z_cm: float) -> tuple[np.ndarray, float]:
183186
candidates = np.zeros((n1))
184187
rmax = 0.0
@@ -226,6 +229,7 @@ def search_monomer_candidates(R: np.ndarray, M: np.ndarray, monomer_candidates:
226229

227230
candidates, rmax = random_list_selection(gamma_ok, gamma_pc, X,Y,Z,R,n1,x_cm,y_cm,z_cm)
228231

232+
# FIXME: this fails once kf > 1.5 LMFAO
229233
candidates[RS_1-k-1] = 1
230234
return candidates, rmax
231235

@@ -270,6 +274,10 @@ def sticking_process(x: float,y: float,z: float,r: float,r_k: float, x_cm: float
270274
distance = np.sqrt(np.power(x2-x1,2) + np.power(y2-y1,2) + np.power(z2-z1,2))
271275

272276
alpha = np.arccos((np.power(r1,2) + np.power(distance,2) - np.power(r2,2))/(2*r1*distance))
277+
if abs((np.power(r1,2) + np.power(distance,2) - np.power(r2,2))/(2*r1*distance)) > 1:
278+
# FIXME: this should never happen!
279+
print(f"{(np.power(r1,2) + np.power(distance,2) - np.power(r2,2))/(2*r1*distance) = }")
280+
exit(-1)
273281
r0 = r1*np.sin(alpha)
274282

275283
# AmBdC = (A+B)/C

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
11
# TunableCCA
2+
Implementation of FracVAL [[[https://www.sciencedirect.com/science/article/pii/S0010465519300323?via%3Dihub][Morán, J. et al. 2019]]] in python.
3+
4+
## TODO
5+
- [ ] Fix PCA bugs
6+
+ [ ] Instability with arcos arguments, tied to monomer size somehow
7+
+ [ ] low fractal dimensions fail
8+
+ [ ] high fractal prefactors fail
9+
+ [ ] yet to be understood infinite loop occurs sometimes
10+
- [ ] Allow distribution functions for monomer radii
11+
- [ ] Parallelize
12+
- [ ] High fractal dimensions are super slow, investigate why

main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
from CCA import CCA_subcluster
77

88
# config
9-
DF = 2.0
9+
DF = 2.7
1010
Kf = 1.0
11-
N = 1024
11+
N = 64
1212
R0 = 0.01
1313
SIGMA = 0
1414
EXT_CASE = 0

0 commit comments

Comments
 (0)