source: trunk/User form factors for Irena/CoreShellShellShell.ipf @ 1182

Last change on this file since 1182 was 1182, checked in by ilavsky, 7 months ago

Fix for IP8

  • Property svn:eol-style set to native
File size: 4.5 KB
Line 
1#pragma TextEncoding = "UTF-8"
2#pragma rtGlobals=3                             // Use modern global access method and strict wave access
3#pragma DefaultTab={3,20,4}             // Set default tab width in Igor Pro 9 and later
4
5//this is form factor and volume function for Irena for Core-Shell-Shell-Shell particles
6//              this can be used os User form factor in Modeling package.
7//              this is a copy of code from NIST Igor package, Core_and_NShell_v40.ipf, orginal form factor function is fThreeShell
8//              Jan Ilavsky, 2022-01-07
9
10//How to use:
11//  -- important --
12//      set contrast in Modeling package to 1, core-shell form factors have rho values (SLD) as part of the form factor...
13//      set constants below to proper for the parameter values. This form factor has too many parameters, some need to be in constants. 
14//      Therefore, you need to use one parameter - C3ShellPar6 - as constant, Irena has limit of 5 form factor parameters.
15//      If needed, you can change what par1-par5 mean, but this may require redefining also volume function   FF_CoreThreeShellVolume
16//              The FF_CoreThreeShellVolume is assuming, that par1, par3, and par5 are shell thicknesses.
17//              *** change therefore both FF_CoreThreeShell AND FF_CoreThreeShellVolume ***
18// Default parameter definitions:
19        //radius -  radius of core [Å]
20        //par1          thickness of shell 1 [Å]
21        //par2          SLD of shell 1
22        //par3          thickness of shell 2 [Å]
23        //par4          SLD of shell 2
24        //par5          thickness of shell 3 [Å]
25
26        //C3ShellCoreSLD                SLD of the core [Å-2]
27        //C3ShellSolventSLD     SLD of the solvent
28        //C3ShellPar6                   SLD of shell 3
29
30
31constant C3ShellCoreSLD         = 22.45                                 //this is rho for core (default SiO2), can be changed here.
32constant C3ShellSolventSLD      = 9.4197                                //this is rho for solvent (default water), can be changed here.
33// Since we are limited to 5 GUI parameters, one more parameter needs to be fixed. Below is defined Par6 which in default code is Shell3SLD.
34constant C3ShellPar6            = 9.42                                  //this is rho for core, can be changed here. Not enough parameters in Irena GUI
35        // water is 9.42 [*10^10]
36        // SiO2 is 22.45 [10^10]
37        // FYI (for testing) delta-rho-squared for H2O-SiO2 is 169.9 10^20. Yu can set shell thicknesses to 0 with Water/SiO2
38        // and get same intensity/curve as with sphere with contrast to 169.9. I have tested this and other edge cases.
39
40
41Function FF_CoreThreeShell(Q,radius, par1,par2,par3,par4,par5)          //returns Form factor for given Q, Radius and Par1-Par5
42        variable Q, radius, par1,par2,par3,par4,par5                                                                                           
43       
44        // variables are:
45        //radius -  radius of core [Å]
46        //par1          thickness of shell 1 [Å]
47        //par2          SLD of shell 1
48        //par3          thickness of shell 2 [Å]
49        //par4          SLD of shell 2
50        //par5          thickness of shell 3 [Å]
51
52        //C3ShellCoreSLD                SLD of the core [Å-2]
53        //C3ShellPar6                   SLD of shell 3
54        //C3ShellSolventSLD     SLD of the solvent
55       
56        // All inputs are in ANGSTROMS
57        //OUTPUT is normalized by the particle volume, and converted to [cm-1]
58       
59       
60        Variable scale,rcore,thick1,thick2,thick3,rhoshel1,rhoshel2,rhoshel3
61        Variable rhocore,rhosolv,bkg
62        rcore = radius
63        rhocore = C3ShellCoreSLD
64        thick1 = par1
65        rhoshel1 = par2
66        thick2 = par3
67        rhoshel2 = par4
68        thick3 = par5
69        rhoshel3 = C3ShellPar6
70        rhosolv = C3ShellSolventSLD
71       
72        // calculates f
73        Variable bes,f,vol,qr,contr,f2
74       
75        // core first, then add in shells
76        qr=Q*rcore
77        contr = rhocore-rhoshel1
78        if(qr == 0)
79                bes = 1
80        else
81                bes = 3*(sin(qr)-qr*cos(qr))/qr^3
82        endif
83        vol = 4*pi/3*rcore^3
84        f = vol*bes*contr
85        //now the shell (1)
86        qr=Q*(rcore+thick1)
87        contr = rhoshel1-rhoshel2
88        if(qr == 0)
89                bes = 1
90        else
91                bes = 3*(sin(qr)-qr*cos(qr))/qr^3
92        endif
93        vol = 4*pi/3*(rcore+thick1)^3
94        f += vol*bes*contr
95        //now the shell (2)
96        qr=Q*(rcore+thick1+thick2)
97        contr = rhoshel2-rhoshel3
98        if(qr == 0)
99                bes = 1
100        else
101                bes = 3*(sin(qr)-qr*cos(qr))/qr^3
102        endif
103        vol = 4*pi/3*(rcore+thick1+thick2)^3
104        f += vol*bes*contr
105        //now the shell (3)
106        qr=Q*(rcore+thick1+thick2+thick3)
107        contr = rhoshel3-rhosolv
108        if(qr == 0)
109                bes = 1
110        else
111                bes = 3*(sin(qr)-qr*cos(qr))/qr^3
112        endif
113        f += vol*bes*contr
114
115        vol = 4*pi/3*(rcore+thick1+thick2+thick3)^3
116       
117        f/=vol          //correct for volumes accounted in here.
118       
119        return (f)
120End
121
122
123Function FF_CoreThreeShellVolume(radius, par1,par2,par3,par4,par5)              //returns the sphere volume, this particle is now normalized by volume of the core.
124        variable radius, par1,par2,par3,par4,par5
125
126        //radius -  radius of core [Å]
127        //par1          thickness of shell 1 [Å]
128        //par2          SLD of shell 1
129        //par3          thickness of shell 2 [Å]
130        //par4          SLD of shell 2
131        //par5          thickness of shell 3 [Å]
132        variable realRad=radius + par1 + par3 + par5
133        return ((4/3)*pi*realRad*realRad*realRad)
134end
135   
Note: See TracBrowser for help on using the repository browser.