Repository navigation
Expand file tree
/
Copy pathBackbone.py
More file actions
100 lines (62 loc) · 3.11 KB
/
Copy pathBackbone.py
File metadata and controls
100 lines (62 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# -*- coding: utf-8 -*-
"""
Created on Wed Aug 24 23:57:04 2022
@author: Laura Stricker, laura.stricker@mat.ethz.ch
"""
import numpy as np
from importlib import reload
import Particle
reload(Particle)
from Particle import Particle
class Backbone:
def __init__(self,timeIndex,time,particles):
self.timeIndex = timeIndex
self.time = time
self.minPathParticleCount = int
self.minPathLength = float
self.extremes = np.ndarray((2,), dtype = object)
self.linearDistanceExtremes = float()
self.totalParticleCount = int
self.largestClusterParticleCount = len(particles)
self.forwardMinParticleCount = int
self.backwardMinParticleCount = int
def calculateLinearDistanceBetweenExtremes(self):
particle1 = self.extremes[0]
particle2 = self.extremes[1]
self.linearDistanceExtremes = particle1.distanceToParticle(particle2)
def checkForErrors(self):
assert self.forwardMinParticleCount == self.backwardMinParticleCount,\
'Min # particles is != in forward and backward burning\n' \
f'time={self.time}\n'\
f'forward burning particle # ={self.forwardMinParticleCount}, \n'\
f'backward burning particle # = {self.backwardMinParticleCount}'
self.minPathParticleCount = self.forwardMinParticleCount
def getSummaryBackwardBurning(self,endParticle,burntParticleCountTot):
self.backwardMinParticleCount = endParticle.backwardBurningTime
self.totalParticleCount = burntParticleCountTot
def getSummaryForwardBurning(self,particles,startParticle,endParticle):
self.forwardMinParticleCount = endParticle.forwardBurningTime
self.getMinPathLength(particles,startParticle,endParticle)
def getMinPathLength(self,particles,startParticle,endParticle):
''' Sum of inteparticle distances along shortest path connecting backbone extremes
It is calculated by going backwards, from one particle to its burner
'''
connectedLength = 0.
particle = endParticle
while particle != startParticle:
burnerIndex = particle.isBurntByParticleIndex
burner = particles[burnerIndex]
dLength = burner.distanceToParticle(particle)
connectedLength = connectedLength + dLength
particle = burner
self.minPathLength = connectedLength
#Debug/output file
def printFileSummary(self,fileHandler):
print("{:6d}".format(self.timeIndex),\
"{:.2f}".format(self.time),\
"{:6d}".format(self.minPathParticleCount),\
"{:.2f}".format(self.minPathLength), \
"{:6d}".format(self.totalParticleCount),\
"{:.2f}".format(self.linearDistanceExtremes),\
"{:6d}".format(self.largestClusterParticleCount),\
file = fileHandler)