1 | # ---------------------------------------------------------------------- |
---|

2 | # FERMI STATISTICS |
---|

3 | # |
---|

4 | # This simple example shows how you can use the Rappture toolkit |
---|

5 | # to handle I/O for a simple simulator--in this case, one that |
---|

6 | # computes Fermi-Dirac statistics. |
---|

7 | # |
---|

8 | # ====================================================================== |
---|

9 | # AUTHOR: Michael McLennan, Purdue University |
---|

10 | # Copyright (c) 2004-2012 HUBzero Foundation, LLC |
---|

11 | # |
---|

12 | # See the file "license.terms" for information on usage and |
---|

13 | # redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|

14 | # ====================================================================== |
---|

15 | |
---|

16 | from math import * |
---|

17 | import sys |
---|

18 | import Rappture |
---|

19 | |
---|

20 | import fermi_io |
---|

21 | from fermi_io import * |
---|

22 | |
---|

23 | # do this right at the start, to handle command line args |
---|

24 | Rappture.interface(sys.argv, fermi_io) |
---|

25 | |
---|

26 | kT = 8.61734e-5 * T |
---|

27 | Emin = Ef - 10*kT |
---|

28 | Emax = Ef + 10*kT |
---|

29 | |
---|

30 | E = Emin; dE = 0.005*(Emax-Emin) |
---|

31 | |
---|

32 | Rappture.driver.put("output.curve(f12).about.label", "Fermi-Dirac Factor") |
---|

33 | Rappture.driver.put("output.curve(f12).xaxis.label", "Energy") |
---|

34 | Rappture.driver.put("output.curve(f12).xaxis.units", "eV") |
---|

35 | path = "output.curve(f12).component.xy" |
---|

36 | |
---|

37 | while E < Emax: |
---|

38 | f = 1.0/(1.0 + exp((E - Ef)/kT)) |
---|

39 | # result.append( [E,f] ) |
---|

40 | value = "%s %s\n" % (f,E) |
---|

41 | Rappture.driver.put(path,value,append=1) |
---|

42 | E += dE |
---|

43 | |
---|