root/trunk/special-functions/coulomb.lisp

Revision 34, 8.3 kB (checked in by lhealy, 9 months ago)

The classes/types in the different contexts are now gathered together
in one place, in *type-names* for the types and in *data-class-name*
for data classes, populated by #'add-data-class. Both defdata and
defmfun-all use the table and so mapping between various names is
consistent. The data class names are now different, *-double-float
and *-single-float replaces *-double and *-single. The regression
tests give the same results as before.

  • Property svn:keywords set to Id
Line 
1;; Coulumb functions
2;; Liam Healy, Sat Mar 18 2006 - 23:23
3;; Time-stamp: <2008-03-09 19:29:18EDT coulomb.lisp>
4;; $Id$
5
6(in-package :gsl)
7
8;;;;****************************************************************************
9;;;; Normalized Hydrogenic Bound States
10;;;;****************************************************************************
11
12(defmfun hydrogenicR-1 (x r)
13  "gsl_sf_hydrogenicR_1_e" ((x :double) (r :double) (ret sf-result))
14  :documentation                        ; FDL
15  "The lowest-order normalized hydrogenic bound state radial
16   wavefunction R_1 := 2Z \sqrt{Z} \exp(-Z r).")
17
18(defmfun hydrogenicR (n l x r)
19  "gsl_sf_hydrogenicR_e"
20  ((n :int) (l :int) (x :double) (r :double) (ret sf-result))
21  :documentation                        ; FDL
22  "The n-th normalized hydrogenic bound state radial wavefunction,
23  R_n := {2 Z^{3/2} \over n^2}  \left({2Z \over n}\right)^l
24  \sqrt{(n-l-1)! \over (n+l)!} \exp(-Z r/n) L^{2l+1}_{n-l-1}(2Z/n r).
25  The normalization is chosen such that the wavefunction \psi is given by
26  \psi(n,l,r) = R_n Y_{lm}.")
27
28;;;;****************************************************************************
29;;;; Coulomb Wave Functions
30;;;;****************************************************************************
31
32;;; Comments are direct from GSL and aren't lispized yet.
33
34(defmfun coulomb-wave-FG (eta x L-F k)
35  "gsl_sf_coulomb_wave_FG_e"
36  ((eta :double) (x :double) (L-F :double) (k :int)
37   (F sf-result) (Fp sf-result) (G sf-result) (Gp sf-result)
38   (exp-F :double) (exp-G :double))
39  :return
40  ((val F) (val Fp) (val G) (val Gp)
41   (dcref exp-F) (dcref exp-G)
42   (err F) (err Fp) (err G) (err Gp))
43  :documentation                        ; FDL
44  "The Coulomb wave functions F_L(\eta,x),
45  G_{L-k}(\eta,x) and their derivatives F'_L(\eta,x),
46  G'_{L-k}(\eta,x) with respect to x.  The parameters are restricted to
47  L, L-k > -1/2}, x > 0 and integer k.  Note that L
48  itself is not restricted to being an integer. The results are stored in
49  the parameters F, G for the function values and Fp,
50  Gp for the derivative values.  If an overflow occurs,
51  :EOVRFLW is signalled and scaling exponents are stored in
52  the modifiable parameters exp-F, exp-G.")
53
54(defmfun coulomb-wave-F-array (L-min eta x fc-array)
55  "gsl_sf_coulomb_wave_F_array"
56  ((L-min :double) ((1- (dim0 fc-array)) :int) (eta :double) (x :double)
57   ((gsl-array fc-array) :pointer) (F-exponent :double))
58  :invalidate (fc-array)
59  :return (fc-array (dcref F-exponent))
60  :documentation                        ; FDL
61  "The Coulomb wave function F_L(\eta,x) for
62  L = Lmin ... Lmin + kmax, storing the results in fc-array.
63  In the case of overflow the exponent is stored in the second value returned.")
64
65(defmfun coulomb-wave-FG-array (L-min eta x fc-array gc-array)
66  "gsl_sf_coulomb_wave_FG_array"
67  ((L-min :double) ((1- (dim0 fc-array)) :int) (eta :double) (x :double)
68   ((gsl-array fc-array) :pointer) ((gsl-array gc-array) :pointer)
69   (F-exponent :double) (G-exponent :double))
70  :return (fc-array gc-array (dcref F-exponent) (dcref G-exponent))
71  :documentation                        ; FDL
72  "The functions F_L(\eta,x),
73  G_L(\eta,x) for L = Lmin ... Lmin + kmax storing the
74  results in fc_array and gc_array.  In the case of overflow the
75  exponents are stored in F_exponent and G_exponent.")
76
77(defmfun coulomb-wave-FGp-array (L-min eta x fc-array fcp-array gc-array gcp-array)
78  "gsl_sf_coulomb_wave_FGp_array"
79  ((L-min :double) ((1- (dim0 fc-array)) :int) (eta :double) (x :double)
80   ((gsl-array fc-array) :pointer) ((gsl-array fcp-array) :pointer)
81   ((gsl-array gc-array) :pointer) ((gsl-array gcp-array) :pointer)
82   (F-exponent :double) (G-exponent :double))
83  :return
84  (fc-array fcp-array gc-array gcp-array
85            (dcref F-exponent) (dcref G-exponent))
86  :documentation                        ; FDL
87  "The functions F_L(\eta,x),
88  G_L(\eta,x) and their derivatives F'_L(\eta,x),
89  G'_L(\eta,x) for L = Lmin ... Lmin + kmax storing the
90  results in fc_array, gc_array, fcp_array and gcp_array.
91  In the case of overflow the exponents are stored in F_exponent
92  and G_exponent.")
93
94(defmfun coulomb-wave-sphF-array (L-min eta x fc-array)
95  "gsl_sf_coulomb_wave_sphF_array"
96  ((L-min :double) ((1- (dim0 fc-array)) :int) (eta :double) (x :double)
97   ((gsl-array fc-array) :pointer) (F-exponent :double))
98  :invalidate (fc-array)
99  :return (fc-array (dcref F-exponent))
100  :documentation                        ; FDL
101  "The Coulomb wave function divided by the argument
102   F_L(\eta, x)/x for L = Lmin ... Lmin + kmax, storing the
103   results in fc_array.  In the case of overflow the exponent is
104   stored in F_exponent. This function reduces to spherical Bessel
105   functions in the limit \eta \to 0.")
106
107;;;;****************************************************************************
108;;;; Coulomb Wave Function Normalization Constant
109;;;;****************************************************************************
110
111(defmfun coulomb-CL (L eta)
112  "gsl_sf_coulomb_CL_e" ((L :double) (eta :double) (ret sf-result))
113  :documentation                        ; FDL
114  "The Coulomb wave function normalization constant C_L(\eta)
115   for L > -1.")
116
117(defmfun coulomb-CL-array (L-min eta cl)
118  "gsl_sf_coulomb_CL_array"
119  ((L-min :double) ((1- (dim0 cl)) :int) (eta :double)
120   ((gsl-array cl) :pointer))
121  :documentation                        ; FDL
122  "The Coulomb wave function normalization constant C_L(\eta)
123   for L = Lmin ... Lmin + kmax, Lmin > -1."
124  :invalidate (cl))
125
126;;;;****************************************************************************
127;;;; Examples and unit test
128;;;;****************************************************************************
129
130#|
131(make-tests coulomb
132  (hydrogenicr-1 1.0d0 2.5d0)
133  (hydrogenicr 3 1 1.0d0 2.5d0)
134  (coulomb-wave-FG 0.0d0 1.0d0 2.0d0 0)
135  (letm ((arr (vector-double-float 3)))
136    (coulomb-wave-F-array  0.0d0 1.0d0 2.0d0 arr)
137    (data arr))
138  (coulomb-wave-fg 1.0d0 2.0d0 2.5d0 1)
139  (letm ((Farr (vector-double-float 3)) (Garr (vector-double-float 3)))
140    (coulomb-wave-FG-array 1.5d0 1.0d0 1.0d0 Farr Garr)
141    (append (coerce (data Farr) 'list) (coerce (data Garr) 'list)))
142  (letm ((arr (vector-double-float 3)))
143    (coulomb-wave-sphF-array  0.0d0 1.0d0 2.0d0 arr) (data arr))
144  (coulomb-cl 1.0d0 2.5d0)
145  (letm ((cl (vector-double-float 3)))
146    (coulomb-CL-array 0.0d0 1.0d0 cl) (data cl)))
147|#
148
149(LISP-UNIT:DEFINE-TEST COULOMB
150  (LISP-UNIT::ASSERT-NUMERICAL-EQUAL
151   (LIST 0.1641699972477976d0 1.8226531089715347d-16)
152   (MULTIPLE-VALUE-LIST (HYDROGENICR-1 1.0d0 2.5d0)))
153  (LISP-UNIT::ASSERT-NUMERICAL-EQUAL
154   (LIST 0.07666468084146327d0 4.203054519905891d-16)
155   (MULTIPLE-VALUE-LIST (HYDROGENICR 3 1 1.0d0 2.5d0)))
156  (LISP-UNIT::ASSERT-NUMERICAL-EQUAL
157   (LIST 0.06203505201137388d0 0.17709857491700906d0
158         3.6050175661599693d0 -5.8282618416439025d0 0.0d0
159         0.0d0 4.3793707124032857d-16
160         1.2502291640824433d-15 3.5328525523867457d-14
161         5.711592064490999d-14)
162   (MULTIPLE-VALUE-LIST
163    (COULOMB-WAVE-FG 0.0d0 1.0d0 2.0d0 0)))
164  (LISP-UNIT::ASSERT-NUMERICAL-EQUAL
165   (LIST
166    #(0.6617816138326813d0 0.3614128577450535d0
167      0.13267757609917497d0))
168   (MULTIPLE-VALUE-LIST
169    (LETM ((ARR (VECTOR-DOUBLE-FLOAT 3)))
170      (COULOMB-WAVE-F-ARRAY 0.0d0 1.0d0 2.0d0 ARR)
171      (DATA ARR))))
172  (LISP-UNIT::ASSERT-NUMERICAL-EQUAL
173   (LIST 0.07161779967468254d0 0.1278101031568499d0
174         2.2510703464871114d0 -1.4245543587641651d0 0.0d0
175         0.0d0 8.269219937869759d-15
176         1.4757362807662922d-14 2.5991577338697564d-13
177         1.644835970887306d-13)
178   (MULTIPLE-VALUE-LIST
179    (COULOMB-WAVE-FG 1.0d0 2.0d0 2.5d0 1)))
180  (LISP-UNIT::ASSERT-NUMERICAL-EQUAL
181   (LIST
182    (LIST 0.035021584603913254d0 0.005752500614202263d0
183          7.116955601984411d-4 6.471726496134135d0
184          27.57457472159366d0 170.56037293106908d0))
185   (MULTIPLE-VALUE-LIST
186    (LETM
187        ((FARR (VECTOR-DOUBLE-FLOAT 3)) (GARR (VECTOR-DOUBLE-FLOAT 3)))
188      (COULOMB-WAVE-FG-ARRAY 1.5d0 1.0d0 1.0d0 FARR GARR)
189      (APPEND (COERCE (DATA FARR) 'LIST)
190              (COERCE (DATA GARR) 'LIST)))))
191  (LISP-UNIT::ASSERT-NUMERICAL-EQUAL
192   (LIST
193    #(0.33089080691634065d0 0.18070642887252675d0
194      0.06633878804958748d0))
195   (MULTIPLE-VALUE-LIST
196    (LETM ((ARR (VECTOR-DOUBLE-FLOAT 3)))
197      (COULOMB-WAVE-SPHF-ARRAY 0.0d0 1.0d0 2.0d0 ARR)
198      (DATA ARR))))
199  (LISP-UNIT::ASSERT-NUMERICAL-EQUAL
200   (LIST 0.0013809146441856027d0 2.759621819430441d-17)
201   (MULTIPLE-VALUE-LIST (COULOMB-CL 1.0d0 2.5d0)))
202  (LISP-UNIT::ASSERT-NUMERICAL-EQUAL
203   (LIST
204    #(0.10842251310207264d0 0.05111086283184191d0
205      0.011428736368066591d0))
206   (MULTIPLE-VALUE-LIST
207    (LETM ((CL (VECTOR-DOUBLE-FLOAT 3)))
208      (COULOMB-CL-ARRAY 0.0d0 1.0d0 CL) (DATA CL)))))
209
Note: See TracBrowser for help on using the browser.