This is the thesis
[matches/honours.git] / thesis / theory.py
index 7a85987..193c6d3 100755 (executable)
@@ -31,6 +31,54 @@ def se_dist(s, Ep, sigma_p, dE, n_max=0.75):
                E += dE
        return results
 
+#
+# @function integrate
+# @purpose integrate function numerically over a range of arguments
+# 
+def integrate(f, xmin, xmax, dx):
+       x = xmin
+       result = 0.00
+       while (x <= xmax):
+               result += f(x) * dx
+               x += dx
+       return result
+
+# @function derivative
+# @purpose get derivative of a function at a value
+def der(f, x, dx):
+       return (f(x + dx) - f(x)) / dx
+
+# 
+# @function tcs
+# @purpose Model S(E)
+def tcs(f, sigma, Emin, Emax, dE):
+       results = []
+       E = Emin
+       while (E < Emax):
+               results.append([E, (1.0 - sigma(0)) * f(-E) - integrate(lambda e : f(e - E) * der(sigma, E, dE), Emin, Emax, dE)])
+               E += dE
+       return results
+
+def delta(x):
+       if (x == 0):
+               return 1.0
+       else:
+               return 0.0
+
+def table(f, xmin, xmax, dx):
+       result = []
+       x = xmin
+       while (x <= xmax):
+               result.append([x, f(x)])
+               x += dx
+       return result
+
+def gaussian(x, sigma):
+       return math.exp(- (x**2.0)/(2.0 * sigma**2.0)) / (sigma * (2.0 * math.pi)**0.50)
+
+def step(x, sigma, T):
+       return 1.0 / (math.exp((x - sigma)/T) + 1.0)
+
 # 
 # @function write_data
 # @purpose Write a list of data to a file suitable for gnuplotting
@@ -43,19 +91,18 @@ def write_data(data, fileName):
                out.write("\n")
        out.close()
 
-def Plot(*args):
-       gnuplot.plot(args)
+def Plot(data):
+       gnuplot.replot(Gnuplot.Data(data, with_="lp"))
 
 
 def main():    
        
-       test = se_dist(4.0, 7.0, 0.2, 0.01)
-       #gnuplot.replot(map(lambda e : [e[0], e[1] + e[2]], test))
-       #gnuplot.replot(map(lambda e : [e[0], e[2]], test))
-       write_data(test, "se_dist.dat") 
+       #test = se_dist(4.0, 7.0, 0.2, 0.01)
+       #write_data(test, "se_dist.dat")        
+       
        
-       print("Press enter to exit")
-       sys.stdin.readline()
+       #print("Press enter to exit")
+       #sys.stdin.readline()
                
        return 0
 

UCC git Repository :: git.ucc.asn.au