Skip to content
Snippets Groups Projects
Commit b42ba4eb authored by U.Mattschas's avatar U.Mattschas
Browse files

Update Particles_software.py. Now with electrons and protons.

parent 60582d05
No related branches found
No related tags found
1 merge request!4Particle
# -*- coding: utf-8 -*-
import random
import numpy as np
class particle:
class Particle:
"""Create angles, mass and velocity to particles on a plane"""
def __init__(self):
"""The angles are created randomly onto a projectet square"""
self.theta=random.uniform(-np.arctan(0.5),np.arctan(0.5))
self.phi=random.uniform(-np.arctan(0.5),np.arctan(0.5))
self.theta = np.random.uniform(-np.arctan(0.5), np.arctan(0.5))
self.phi = np.random.uniform(-np.arctan(0.5), np.arctan(0.5))
"""If we want two different masses (electron, proton), I have here
created them with equal probability"""
self.m=0.511 #MeV
self.e = np.random.uniform(1, 0)
if self.e > 0.5:
self.m = 0.511 #MeV
else:
self.m = 938.272 #Mev
"""Velocity: random velocity between X and Y"""
self.v=random.uniform(0.2,0.6) #Natural units
self.v = np.random.uniform(0.2, 0.6) #Natural units
#Alter the range of velocities
#Perhaps make vx, vy, vz
"""Charge, 1,-1"""
self.k=random.uniform(1,0)
self.k = np.random.uniform(1, 0)
if self.k > 0.5:
q=1
q = 1
else:
q=-1
q = -1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment