X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=thesis%2Ftheory.py;h=193c6d3f4f33f99a41b8b8ba2e5b4ce3c5d3f95e;hb=e5cdff35e02be32150579315db17fba16ce6d459;hp=7a85987ef59682c3e5f3cd6833b40bd9d8f91b7e;hpb=476dde3dd6eb6fb880e4a170d8e5e11af37e0457;p=matches%2Fhonours.git diff --git a/thesis/theory.py b/thesis/theory.py index 7a85987e..193c6d3f 100755 --- a/thesis/theory.py +++ b/thesis/theory.py @@ -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