from __future__ import division
# Initialisation of Variables
d=10.2#............#Engine bore in cm
spo=0.6#............#Spark plug offset in cm
vf=15.8#............#Average flame speed in m/s
thetas=20#.............#The angle of the crank when spark plug is fired
theta=6.5#..........#Angle by which the Engine rotates for combustion to develop (degree)
N=1200#................#Engine rpm
#calculations
dmax=(0.5*d)+spo#.........#Max distance of flame travel in cm
tf=(dmax)/(vf*100)#................#Time of flame travel in seconds
degs=(N/60)*360#...................#Conversion of engine rpm into degree/second
ctheta=tf*degs#...............#Crank angle for flame travel in degree
tc=theta/degs#..................#time for combustion to develop in seconds
top=tf+tc#......................#Time for one combustion process in seconds
thetatot=theta+ctheta#................#Total crank rotation in degree
thetacp = thetatot-thetas#..........#Crank position
print "Time for one combustion process = %0.2e seconds "%top
print "The crank position is = %0.2f degree"%thetacp
from __future__ import division
# Initialisation of Variables
dp=22#............#Delay period in degree
cp=17#...............#Combustion period in degree
dper=14#...............#Delay Percentage
#Calculations
thetad=dp/2#.........#Full throttle half speed will result in delay angle being reduced for the same time
#Thus ignition timing should be arranged so that the total of thetad+cp ends 13 degree after TDC
tsp=(thetad+cp)-13#............#Time of spark in degree
print "The time of spark = %0.2f Degrees before TDC "%tsp
#Half throttle half speed will result in an increase of 14% in delay time over that at full throttle half speed
theta=(dper*thetad)/100#
dtheta=thetad+theta#............#Delay angle
tp=dtheta+cp#................#Total period
tsp=tp-13#..............#
print "Time of spark = %0.2f degrees before TDC"%tsp