Debian Codegraph @

artemis_parts/macro.pl

raw
1 ## -*- cperl -*-
2 ##
3 ## This file is part of Artemis, copyright (c) 2002-2008 Bruce Ravel
4 ##
5 ## This section of the code contains subroutines associated with
6 ## ifeffit macros
7
8
9
10 sub write_macros {
11 my $string = "
12 macro startup
13 \"Artemis startup message, used to set character size and font\"
14 startup.x = range(0.1,1,0.1)
15 startup.y = zeros(10)
16 newplot(startup.x, startup.y, nogrid, ymin=0, ymax=1, color=black, charsize=$config{plot}{charsize}, charfont=$config{plot}{charfont})
17 plot_text(0.4, 0.5, text=\"Welcome to Artemis\")
18 erase \@group startup
19 end macro
20
21 macro fix_chik
22 \"repair chi(k) data group that is not on a uniform k grid\"
23 set(fix___a.k = range(0, ceil(\$1.k), 0.05))
24 set(fix___floor = floor(\$1.k) - 0.05)
25 set(fix___a.kk = range(0, fix___floor, 0.05))
26 set(fix___n = npts(fix___a.kk))
27 set(fix___a.cc = zeros(fix___n))
28 set(fix___a.x = join(fix___a.kk, \$1.k))
29 set(fix___a.y = join(fix___a.cc, \$1.chi))
30 set(fix___a.chi = rebin(fix___a.x, fix___a.y, fix___a.k))
31 set(\$1.k = fix___a.k)
32 set(\$1.chi = fix___a.chi)
33 erase \@group fix___a fix___floor fix___n
34 end macro
35
36 macro eins
37 \"Fit Einstein temperature and offset for a MASS1, MASS2 given data in group eins\"
38 unguess
39 set(eins_hbarc = 1973.270533,
40 eins_boltz = 8.61738e-5,
41 eins_amu2ev = 9.3149432e8)
42 set eins_prefac = eins_hbarc*eins_hbarc/(2*eins_boltz*eins_amu2ev)
43 set eins_rmass = 1/(1/\$1+1/\$2)
44 guess(eins_theta = 300, eins_offset=0.001)
45 def eins.vec = eins_theta/(2*eins.1)
46 def eins.thvec = tanh(eins.vec)
47 def eins.y = eins_prefac/(eins.thvec*eins_rmass*eins_theta) + eins_offset
48 def eins.resid = eins.y-eins.2
49 #minimize(eins.resid, uncertainty=eins.3)
50 minimize(eins.resid)
51 def eins.xx = indarr(ceil(eins.1) + 50)
52 def eins.ovec = eins_theta/(2*eins.xx)
53 def eins.thovec = tanh(eins.ovec)
54 def eins.yy = eins_prefac/(eins.thovec*eins_rmass*eins_theta) + eins_offset
55 end macro
56
57
58 ## end of Artemis' macros
59 ##
60 ##
61 ";
62 return $string;
63 };
64
65 ## END OF MACROS SUBSECTION
66 ##########################################################################################