# OneCompartAspirin.py
# One Compartment model of drug dosage of aspirin

import math

def OneCompartAspirin(DT = 0.01, simLength = 8):
	numIterations = int(simLength/DT) + 1
	print "         t   Plasma Concentration"
	half_life = 3.2
	plasma_volume = 3000
	aspirin_in_plasma = 2 * 325 * 1000
	elimination_constant = -math.log(0.5) / half_life
	
	elimination = elimination_constant * aspirin_in_plasma
	plasma_concentration = aspirin_in_plasma / plasma_volume
	plasma_concentrationLst = [plasma_concentration]
	t = 0
	timeLst = [0]
	print '%10.2f\t%12.2f' % (t, plasma_concentration)
	for i in range(1, numIterations):
	    t = i * DT
	    timeLst.append(t)
	    elimination = elimination_constant * aspirin_in_plasma
	    aspirin_in_plasma = aspirin_in_plasma - elimination * DT
	    plasma_concentration = aspirin_in_plasma / plasma_volume
	    plasma_concentrationLst.append(plasma_concentration)
	    print '%10.2f\t%12.2f' % (t, plasma_concentration)


OneCompartAspirin()
