source: sans/Analysis/branches/ajj_23APR07/XOPs/SANSAnalysis/XOP/TwoPhase.c @ 188

Last change on this file since 188 was 188, checked in by srkline, 15 years ago

removed depricated #pragma statement for structure alignment and replaced with proper includes as directed by WM.

Mac resource file has additional threadsafe declarations

File size: 8.7 KB
Line 
1/*      TwoPhaseFit.c
2
3*/
4
5
6#include "XOPStandardHeaders.h"                 // Include ANSI headers, Mac headers, IgorXOP.h, XOP.h and XOPSupport.h
7#include "SANSAnalysis.h"
8#include "libSANSAnalysis.h"
9#include "TwoPhase.h"
10
11// scattering from the Teubner-Strey model for microemulsions - hardly needs to be an XOP...
12int
13TeubnerStreyModelX(FitParamsPtr p)
14{
15        double *dp;                             // Pointer to double precision wave data.
16        float *fp;                              // Pointer to single precision wave data.
17        double q;
18       
19        if (p->waveHandle == NIL) {
20                SetNaN64(&p->result);
21                return NON_EXISTENT_WAVE;
22        }
23   
24        q = p->x;
25       
26        switch(WaveType(p->waveHandle)){                        // We can handle single and double precision coefficient waves.
27                case NT_FP32:
28                        fp= WaveData(p->waveHandle);
29            SetNaN64(&p->result);
30                        return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07           
31                case NT_FP64:
32                        dp= WaveData(p->waveHandle);
33                        p->result = TeubnerStreyModel(dp,q);                                                                                                                           
34                        return 0;
35                default:                                                                // We can't handle this wave data type.
36                        SetNaN64(&p->result);
37                        return REQUIRES_SP_OR_DP_WAVE;
38        }
39       
40        return 0;
41}
42
43int
44Power_Law_ModelX(FitParamsPtr p)
45{
46        double *dp;                             // Pointer to double precision wave data.
47        float *fp;                              // Pointer to single precision wave data.
48        double q;
49       
50        if (p->waveHandle == NIL) {
51                SetNaN64(&p->result);
52                return NON_EXISTENT_WAVE;
53        }
54       
55        q= p->x;
56       
57        switch(WaveType(p->waveHandle)){                        // We can handle single and double precision coefficient waves.
58                case NT_FP32:
59                        fp= WaveData(p->waveHandle);
60                        SetNaN64(&p->result);
61                        return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 
62                case NT_FP64:
63                        dp= WaveData(p->waveHandle);
64                        p->result = Power_Law_Model(dp,q);
65                        return 0;
66                default:                                                                // We can't handle this wave data type.
67                        SetNaN64(&p->result);
68                        return REQUIRES_SP_OR_DP_WAVE;
69        }
70       
71        return 0;
72}
73
74
75int
76Peak_Lorentz_ModelX(FitParamsPtr p)
77{
78        double *dp;                             // Pointer to double precision wave data.
79        float *fp;                              // Pointer to single precision wave data.
80        double q;
81       
82        if (p->waveHandle == NIL) {
83                SetNaN64(&p->result);
84                return NON_EXISTENT_WAVE;
85        }
86       
87        q= p->x;
88       
89        switch(WaveType(p->waveHandle)){                        // We can handle single and double precision coefficient waves.
90                case NT_FP32:
91                        fp= WaveData(p->waveHandle);
92                        SetNaN64(&p->result);
93                        return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 
94                case NT_FP64:
95                        dp= WaveData(p->waveHandle);
96                        p->result = Peak_Lorentz_Model(dp,q);
97                        return 0;
98                default:                                                                // We can't handle this wave data type.
99                        SetNaN64(&p->result);
100                        return REQUIRES_SP_OR_DP_WAVE;
101        }
102       
103        return 0;
104}
105
106int
107Peak_Gauss_ModelX(FitParamsPtr p)
108{
109        double *dp;                             // Pointer to double precision wave data.
110        float *fp;                              // Pointer to single precision wave data.
111        double q;
112       
113        if (p->waveHandle == NIL) {
114                SetNaN64(&p->result);
115                return NON_EXISTENT_WAVE;
116        }
117       
118        q= p->x;
119       
120        switch(WaveType(p->waveHandle)){                        // We can handle single and double precision coefficient waves.
121                case NT_FP32:
122                        fp= WaveData(p->waveHandle);
123                        SetNaN64(&p->result);
124                        return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 
125                case NT_FP64:
126                        dp= WaveData(p->waveHandle);
127                        p->result = Peak_Gauss_Model(dp,q);
128                        return 0;
129                default:                                                                // We can't handle this wave data type.
130                        SetNaN64(&p->result);
131                        return REQUIRES_SP_OR_DP_WAVE;
132        }
133       
134        return 0;
135}
136
137int
138Lorentz_ModelX(FitParamsPtr p)
139{
140        double *dp;                             // Pointer to double precision wave data.
141        float *fp;                              // Pointer to single precision wave data.
142        double q;
143       
144        if (p->waveHandle == NIL) {
145                SetNaN64(&p->result);
146                return NON_EXISTENT_WAVE;
147        }
148       
149        q= p->x;
150       
151        switch(WaveType(p->waveHandle)){                        // We can handle single and double precision coefficient waves.
152                case NT_FP32:
153                        fp= WaveData(p->waveHandle);
154                        SetNaN64(&p->result);
155                        return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 
156                case NT_FP64:
157                        dp= WaveData(p->waveHandle);
158                        p->result=Lorentz_Model(dp,q);
159                        return 0;
160                default:                                                                // We can't handle this wave data type.
161                        SetNaN64(&p->result);
162                        return REQUIRES_SP_OR_DP_WAVE;
163        }
164       
165        return 0;
166}
167
168int
169FractalX(FitParamsPtr p)
170{
171        double *dp;                             // Pointer to double precision wave data.
172        float *fp;                              // Pointer to single precision wave data.
173        double q;
174       
175        if (p->waveHandle == NIL) {
176                SetNaN64(&p->result);
177                return NON_EXISTENT_WAVE;
178        }
179       
180        q= p->x;
181       
182        switch(WaveType(p->waveHandle)){                        // We can handle single and double precision coefficient waves.
183                case NT_FP32:
184                        fp= WaveData(p->waveHandle);           
185                        SetNaN64(&p->result);
186                        return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 
187                case NT_FP64:
188                        dp= WaveData(p->waveHandle);
189            p->result = Fractal(dp,q);
190                        return 0;
191                default:                                                                // We can't handle this wave data type.
192                        SetNaN64(&p->result);
193                        return REQUIRES_SP_OR_DP_WAVE;
194        }
195       
196        return 0;
197}
198
199int
200DAB_ModelX(FitParamsPtr p)
201{
202        double *dp;                             // Pointer to double precision wave data.
203        float *fp;                              // Pointer to single precision wave data.
204        double q;
205       
206        if (p->waveHandle == NIL) {
207                SetNaN64(&p->result);
208                return NON_EXISTENT_WAVE;
209        }
210       
211        q= p->x;
212       
213        switch(WaveType(p->waveHandle)){                        // We can handle single and double precision coefficient waves.
214                case NT_FP32:
215                        fp= WaveData(p->waveHandle);
216                        SetNaN64(&p->result);
217                        return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 
218                case NT_FP64:
219                        dp= WaveData(p->waveHandle);
220                        p->result = DAB_Model(dp,q);
221                        return 0;
222                default:                                                                // We can't handle this wave data type.
223                        SetNaN64(&p->result);
224                        return REQUIRES_SP_OR_DP_WAVE;
225        }
226       
227        return 0;
228}
229
230// G. Beaucage's Unified Model (1-4 levels)
231//
232int
233OneLevelX(FitParamsPtr p)
234{
235        double *dp;                             // Pointer to double precision wave data.
236        float *fp;                              // Pointer to single precision wave data.
237        double q;
238       
239        if (p->waveHandle == NIL) {
240                SetNaN64(&p->result);
241                return NON_EXISTENT_WAVE;
242        }
243       
244        q= p->x;
245       
246        switch(WaveType(p->waveHandle)){                        // We can handle single and double precision coefficient waves.
247                case NT_FP32:
248                        fp= WaveData(p->waveHandle);
249                        SetNaN64(&p->result);
250                        return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 
251                case NT_FP64:
252                        dp= WaveData(p->waveHandle);
253                        p-> result = OneLevel(dp,q);
254                        return 0;
255                default:                                                                // We can't handle this wave data type.
256                        SetNaN64(&p->result);
257                        return REQUIRES_SP_OR_DP_WAVE;
258        }
259       
260        return 0;
261}
262
263// G. Beaucage's Unified Model (1-4 levels)
264//
265int
266TwoLevelX(FitParamsPtr p)
267{
268        double *dp;                             // Pointer to double precision wave data.
269        float *fp;                              // Pointer to single precision wave data.
270        double q;
271       
272        if (p->waveHandle == NIL) {
273                SetNaN64(&p->result);
274                return NON_EXISTENT_WAVE;
275        }
276       
277        q= p->x;
278       
279        switch(WaveType(p->waveHandle)){                        // We can handle single and double precision coefficient waves.
280                case NT_FP32:
281                        fp= WaveData(p->waveHandle);
282                        SetNaN64(&p->result);
283                        return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 
284                case NT_FP64:
285                        dp= WaveData(p->waveHandle);
286                        p->result = TwoLevel(dp, q);
287                        return 0;
288                default:                                                                // We can't handle this wave data type.
289                        SetNaN64(&p->result);
290                        return REQUIRES_SP_OR_DP_WAVE;
291        }
292       
293        return 0;
294}
295
296// G. Beaucage's Unified Model (1-4 levels)
297//
298int
299ThreeLevelX(FitParamsPtr p)
300{
301        double *dp;                             // Pointer to double precision wave data.
302        float *fp;                              // Pointer to single precision wave data.
303        double q;
304       
305        if (p->waveHandle == NIL) {
306                SetNaN64(&p->result);
307                return NON_EXISTENT_WAVE;
308        }
309       
310        q= p->x;
311       
312        switch(WaveType(p->waveHandle)){                        // We can handle single and double precision coefficient waves.
313                case NT_FP32:
314                        fp= WaveData(p->waveHandle);
315                        SetNaN64(&p->result);
316                        return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 
317                case NT_FP64:
318                        dp= WaveData(p->waveHandle);
319                        p->result = ThreeLevel(dp, q);
320                        return 0;
321                default:                                                                // We can't handle this wave data type.
322                        SetNaN64(&p->result);
323                        return REQUIRES_SP_OR_DP_WAVE;
324        }
325       
326        return 0;
327}
328
329// G. Beaucage's Unified Model (1-4 levels)
330//
331int
332FourLevelX(FitParamsPtr p)
333{
334        double *dp;                             // Pointer to double precision wave data.
335        float *fp;                              // Pointer to single precision wave data.
336        double q;
337       
338        if (p->waveHandle == NIL) {
339                SetNaN64(&p->result);
340                return NON_EXISTENT_WAVE;
341        }
342       
343        q= p->x;
344       
345        switch(WaveType(p->waveHandle)){                        // We can handle single and double precision coefficient waves.
346                case NT_FP32:
347                        fp= WaveData(p->waveHandle);
348                        SetNaN64(&p->result);
349                        return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07                   
350                case NT_FP64:
351                        dp= WaveData(p->waveHandle);
352                        p->result = FourLevel(dp,q);
353                        return 0;
354                default:                                                                // We can't handle this wave data type.
355                        SetNaN64(&p->result);
356                        return REQUIRES_SP_OR_DP_WAVE;
357        }
358       
359        return 0;
360}
361
362
363///////////end of XOP
364
365
Note: See TracBrowser for help on using the repository browser.