Commit 1fdce0b1 authored by Breno Rilho Lemos's avatar Breno Rilho Lemos 💬
Browse files

Attribute right colors to particles

parent c0ebf3ff
......@@ -22,8 +22,8 @@ exec(compile(open(filename).read(), filename, 'exec'))
# Set animation parameters
r_part = float(argv[0]) # Particle radius
simulated_t = 0.015
duration = int(argv[1])
simulated_t = 0.02 # in microsseconds
duration = int(argv[1]) # in seconds
fps = 24
resolution_percent = 100
......
......@@ -59,7 +59,9 @@ class genDriver(animationDriver): # A driver for particle generators
#loop over particles
for i in range(0, self.N_particles):
charge = random.choice([+1,-1])
part = ParticlePropagator(i,x,y,z,charge)
mass = random.choice([0.000510999, 0.13957, 0.105658, 0.938272, 0.493677]) # Available mass values
part = ParticlePropagator(i,x,y,z,charge,mass)
part.SetType()
part.SetMagneticField()
part.SetProperties(random.gauss(0,self.par1),random.gauss(0,self.par1),random.gauss(0,self.par1))
particles.append(part)
......@@ -87,6 +89,7 @@ class dataDriver(animationDriver): # A driver for data from files.
Py = lines[i].split(' ')[6]
Pz = lines[i].split(' ')[7]
part = ParticlePropagator(i,float(x),float(y),float(z),float(charge),float(mass))
part.SetType()
part.SetMagneticField(0.5)
part.SetProperties(float(Px),float(Py),float(Pz))
particles.append(part)
......
-7.7313e-05 0.00169525 0.194818 0.938272 1 0.569026 -0.154209 0.0875314
-7.7313e-05 0.00169525 0.194818 0.13957 1 -0.0285533 -0.515488 -0.10641
-7.7313e-05 0.00169525 0.194818 0.938272 1 -0.364617 -0.516414 -0.456784
-7.7313e-05 0.00169525 0.194818 0.938272 1 0.853032 0.315083 -0.376617
-7.7313e-05 0.00169525 0.194818 0.105658 1 0.0770387 -0.354769 -0.360806
-7.7313e-05 0.00169525 0.194818 0.493677 -1 0.110384 0.354777 -0.475506
-7.7313e-05 0.00169525 0.194818 0.938272 1 -0.439098 -0.298059 -0.593228
-7.7313e-05 0.00169525 0.194818 0.105658 -1 -0.266573 -0.226942 -0.650483
-7.7313e-05 0.00169525 0.194818 0.000510999 -1 -0.104689 0.0266886 -0.170293
-7.7313e-05 0.00169525 0.194818 0.000510999 1 0.125064 0.0363519 -0.011768
-7.7313e-05 0.00169525 0.194818 0.493677 -1 -0.437909 0.156564 -1.18982
-7.7313e-05 0.00169525 0.194818 0.13957 -1 -0.246104 0.0427121 -0.358677
-7.7313e-05 0.00169525 0.194818 0.105658 -1 -0.32358 -0.164307 -1.02868
-7.7313e-05 0.00169525 0.194818 0.13957 1 0.0828759 0.461309 -1.3406
-7.7313e-05 0.00169525 0.194818 0.13957 1 -0.315236 -0.0588641 -0.513889
-7.7313e-05 0.00169525 0.194818 0.000510999 -1 -0.579311 -0.68716 0.0947535
-7.7313e-05 0.00169525 0.194818 0.13957 1 -0.38638 0.712815 -0.617333
-7.7313e-05 0.00169525 0.194818 0.493677 1 0.555815 -0.303027 -0.991317
-7.7313e-05 0.00169525 0.194818 0.13957 -1 0.155188 0.138202 -0.493527
-7.7313e-05 0.00169525 0.194818 0.493677 1 -0.424263 0.295176 -1.57269
-7.7313e-05 0.00169525 0.194818 0.000510999 -1 0.0328637 -0.0323634 -0.0524468
-7.7313e-05 0.00169525 0.194818 0.938272 1 -0.157325 -0.380165 -1.17522
-7.7313e-05 0.00169525 0.194818 0.493677 1 -0.415708 0.280715 -1.52303
-7.7313e-05 0.00169525 0.194818 0.000510999 1 -0.729816 1.1823 -4.60274
......@@ -12,6 +12,12 @@ class Particle:
self.z=z
self.charge=charge
self.mass = mass
def SetType(self):
p_mass = {"Electron":0.000510999, "Pion":0.13957, "Muon":0.105658, "Proton":0.938272, "Kaon":0.493677}
self.p_type = "Unknown"
for p_type in p_mass:
if p_mass[p_type] == self.mass:
self.p_type = p_type
def PrintPosition(self):
print(str(self.x) + " ; " + str(self.y) + " ; " + str(self.z))
def GetPosition(self):
......
......@@ -54,13 +54,14 @@ def addCameras():
## Returns a list of blender objects
def createSceneParticles(particles):
# Associate particles and colors
particle_types = ["Electron","Pion","Muon","Proton","Kaon"]
particle_types = ["Electron","Pion","Muon","Proton","Kaon","Unknown"]
clRed = (1, 0, 0)
clGreen = (0, 1, 0)
clBlue = (0, 0, 1)
clMagenta = (0.75, 0, 1)
clYellow = (1, 1, 0)
particle_colors = {"Electron":clRed, "Pion":clGreen, "Muon":clBlue, "Proton":clMagenta, "Kaon": clYellow}
clWhite = (255, 255, 255)
particle_colors = {"Electron":clRed, "Pion":clGreen, "Muon":clBlue, "Proton":clMagenta, "Kaon": clYellow, "Unknown": clWhite}
#Create Materials
for type in particle_types:
......@@ -74,7 +75,7 @@ def createSceneParticles(particles):
blender_particles=[]
n_particles=len(particles)
for particle in particles:
this_type=random.choice(particle_types) #TO DO: make this not random, but according to file data
this_type=particle.p_type
print("Adding Sphere - Particle " + str(len(blender_particles))+" of "+str(n_particles-1)+" - "+this_type)
bpy.ops.mesh.primitive_uv_sphere_add()
this_particle = bpy.context.object
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment