Commit 98be41b9 authored by Zoheyr Doctor's avatar Zoheyr Doctor 🔭
Browse files

added some beginning code to binary.py

parent 0e92b11d
import numpy as np
class Binary:
def __init__(self,
r1=10.,
r2=10.,
c1='black',
c2='black',
inclination=50.,
azimuth=30.,
phase=0.,
frame_rate = 30.
omega = 2.
):
"""
A class for representing binaries.
Parameters
----------
m1,m2: floats
masses of 1st and 2nd star, repsectively
c1,c2: matplotlib color
colors of 1st and 2nd star, respectively
inclination: float
inclination angle of binary wrt viewer
in degrees, between [0,90] deg.
azimuth: float
azimuthal angle of viewer in coordinates
of the binary, between [0,360] deg.
phase: float
phase of the binary, between [0,360] deg.
frame_rate: float
frames per second
omega: float
rotations per second
"""
self.m1 = m1
self.m2 = m2
self.c1 = c1
self.c2 = c2
self.alpha = alpha
self.beta = beta
self.gamma = gamma
self.precession='off'
self._D = np.identity(3)
self._C = np.identity(3)
self._B = np.identity(3)
@property
def alpha_rad(self):
return self.alpha*np.pi/180.
@property
def beta_rad(self):
return self.beta*np.pi/180.
@property
def gamma_rad(self):
return self.gamma*np.pi/180.
@property
def phase1(self):
return self._phase1
@phase1.setter
def phase1(self,gamma_rad):
self._phase1 = gamma_rad % 2*np.pi
@property
def phase2(self):
return self.phase1+np.pi
def orbit(self):
self.phase1 = self.phase1 + self.omega/self.frame_rate
@property
def Dmatrix(self):
self._D[0,0] = self._D[1,1] = np.cos(self.alpha*np.pi/180..)
self._D[1,0] = -np.sin(self.alpha*np.pi/180.)
self._D[0,1] = np.sin(self.alpha*np.pi/180.)
return self._D
@property
def Cmatrix(self):
self._C[1,1] = self._C[2,2] = np.cos(self.beta*np.pi/180.)
self._C[2,1] = -np.sin(self.beta*np.pi/180.)
self._C[1,2] = np.sin(self.beta*np.pi/180.)
return self._C
@property
def Bmatrix(self):
self._B[0,0] = self._B[1,1] = np.cos(self.gamma*np.pi/180..)
self._B[1,0] = -np.sin(self.gamma*np.pi/180.)
self._B[0,1] = np.sin(self.gamma*np.pi/180.)
return self._B
@property
def Amatrix(self):
return np.matmul(np.matmul(self.Bmatrix,self.Cmatrix),self.Dmatrix)
@property
def pos1(self):
"""
position of primary in XYZ coordinates of binary plane
"""
def project(self):
class Single:
"""
A class to define single stars.
"""
def __init__(self,
r1,
r2,
chi=None,
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