#
source:
sans/Dev/trunk/NCNR_User_Procedures/Analysis/Models/NewModels_2006/FlexCyl_EllipCross_v40.ipf
@
570

Revision 570, 5.5 KB checked in by srkline, 5 years ago (diff) |
---|

Line | |
---|---|

1 | #pragma rtGlobals=1 // Use modern global access method. |

2 | #pragma IgorVersion=6.1 |

3 | |

4 | #include "FlexibleCylinder_v40" |

5 | |

6 | /////////////////////////// |

7 | // plots the scattering from a flexible cylinder with an |

8 | // elliptical cross-section |

9 | // |

10 | // same chain calculation as flexible cylinder, |

11 | // correcting for a different cross-section |

12 | // |

13 | // Bergstrom / Pedersen reference in Langmuir |

14 | // |

15 | // Contains Wei-Ren's corrections for the chain model July 2006 |

16 | // |

17 | // |

18 | Proc PlotFlexCyl_Ellip(num,qmin,qmax) |

19 | Variable num=128,qmin=0.001,qmax=0.7 |

20 | Prompt num "Enter number of data points for model: " |

21 | Prompt qmin "Enter minimum q-value (A^-1) for model: " |

22 | Prompt qmax "Enter maximum q-value (A^-1) for model: " |

23 | |

24 | Make/O/D/n=(num) xwave_fleell,ywave_fleell |

25 | xwave_fleell = alog(log(qmin) + x*((log(qmax)-log(qmin))/num)) |

26 | Make/O/D coef_fleell = {1.,1000,100,20,1.5,1e-6,6.3e-6,0.0001} |

27 | make/o/t parameters_fleell = {"scale","Contour Length (A)","Kuhn Length, b (A)","Minor Radius (a) (A)","Axis Ratio = major/a","SLD cylinder (A^-2)","SLD solvent (A^-2)","bkgd (arb)"} |

28 | Edit parameters_fleell,coef_fleell |

29 | |

30 | Variable/G root:g_fleell |

31 | g_fleell := FlexCyl_Ellip(coef_fleell,ywave_fleell,xwave_fleell) |

32 | Display ywave_fleell vs xwave_fleell |

33 | ModifyGraph log=1,marker=29,msize=2,mode=4 |

34 | Label bottom "q (A\\S-1\\M)" |

35 | Label left "Intensity (cm\\S-1\\M)" |

36 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |

37 | |

38 | AddModelToStrings("FlexCyl_Ellip","coef_fleell","parameters_fleell","fleell") |

39 | End |

40 | |

41 | // - sets up a dependency to a wrapper, not the actual SmearedModelFunction |

42 | Proc PlotSmearedFlexCyl_Ellip(str) |

43 | String str |

44 | Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4) |

45 | |

46 | // if any of the resolution waves are missing => abort |

47 | if(ResolutionWavesMissingDF(str)) //updated to NOT use global strings (in GaussUtils) |

48 | Abort |

49 | endif |

50 | |

51 | SetDataFolder $("root:"+str) |

52 | |

53 | // Setup parameter table for model function |

54 | Make/O/D smear_coef_fleell = {1.,1000,100,20,1.5,1e-6,6.3e-6,0.0001} |

55 | make/o/t smear_parameters_fleell = {"scale","Contour Length (A)","Kuhn Length, b (A)","Minor Radius (a) (A)","Axis Ratio = major/a","SLD cylinder (A^-2)","SLD solvent (A^-2)","bkgd (arb)"} |

56 | Edit smear_parameters_fleell,smear_coef_fleell //display parameters in a table |

57 | |

58 | // output smeared intensity wave, dimensions are identical to experimental QSIG values |

59 | // make extra copy of experimental q-values for easy plotting |

60 | Duplicate/O $(str+"_q") smeared_fleell,smeared_qvals // |

61 | SetScale d,0,0,"1/cm",smeared_fleell // |

62 | |

63 | Variable/G gs_fleell=0 |

64 | gs_fleell := fSmearedFlexCyl_Ellip(smear_coef_fleell,smeared_fleell,smeared_qvals) //this wrapper fills the STRUCT |

65 | |

66 | Display smeared_fleell vs smeared_qvals // |

67 | ModifyGraph log=1,marker=29,msize=2,mode=4 |

68 | Label bottom "q (A\\S-1\\M)" |

69 | Label left "I(q) (cm\\S-1\\M)" |

70 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |

71 | |

72 | SetDataFolder root: |

73 | AddModelToStrings("SmearedFlexCyl_Ellip","smear_coef_fleell","smear_parameters_fleell","fleell") |

74 | End |

75 | |

76 | |

77 | |

78 | |

79 | //AAO version, uses XOP if available |

80 | // simply calls the original single point calculation with |

81 | // a wave assignment (this will behave nicely if given point ranges) |

82 | Function FlexCyl_Ellip(cw,yw,xw) : FitFunc |

83 | Wave cw,yw,xw |

84 | |

85 | #if exists("FlexCyl_EllipX") |

86 | yw = FlexCyl_EllipX(cw,xw) |

87 | #else |

88 | yw = fFlexCyl_Ellip(cw,xw) |

89 | #endif |

90 | return(0) |

91 | End |

92 | |

93 | // |

94 | Function fFlexCyl_Ellip(ww,x) :FitFunc |

95 | Wave ww |

96 | Variable x |

97 | |

98 | //nice names to the input params |

99 | //ww[0] = scale |

100 | //ww[1] = L [A] |

101 | //ww[2] = B [A] |

102 | //ww[3] = rad [A] cross-sectional radius |

103 | //ww[4] = ellRatio = major/minor axis (greater than one) |

104 | //ww[5] = sld cylinder [A^-2] |

105 | //ww[6] = sld solvent |

106 | //ww[7] = bkg [cm-1] |

107 | Variable scale,L,B,bkg,rad,qr,cont,ellRatio,sldc,slds |

108 | |

109 | scale = ww[0] |

110 | L = ww[1] |

111 | B = ww[2] |

112 | rad = ww[3] |

113 | ellRatio = ww[4] |

114 | sldc = ww[5] |

115 | slds = ww[6] |

116 | bkg = ww[7] |

117 | |

118 | cont = sldc-slds |

119 | qr = x*rad //used for cross section contribution only |

120 | |

121 | //local variables |

122 | Variable flex,crossSect |

123 | |

124 | flex = Sk_WR(x,L,B) //Wei-Ren's calculations, do not have cross section |

125 | |

126 | //calculate cross section contribution - Eqns.(28) &(29) (approximate) |

127 | //use elliptical cross-section here |

128 | crossSect = EllipticalCross_fn(x,rad,(rad*ellRatio)) |

129 | |

130 | //normalize form factor by multiplying by cylinder volume * cont^2 |

131 | // then convert to cm-1 by multiplying by 10^8 |

132 | // then scale = phi |

133 | |

134 | flex *= crossSect |

135 | flex *= Pi*rad*rad*ellRatio*L |

136 | flex *= cont^2 |

137 | flex *= 1.0e8 |

138 | |

139 | return (scale*flex + bkg) |

140 | |

141 | end |

142 | ////////////// flex chain - with excluded volume |

143 | |

144 | Function EllipticalCross_fn(qq,a,b) |

145 | Variable qq,a,b |

146 | |

147 | Make/O/D/N=100 ellip |

148 | SetScale x,0,(pi/2),ellip |

149 | |

150 | ellip = bessJ(1,(qq*sqrt(a^2*sin(x)^2+b^2*cos(x)^2))) / (qq*sqrt(a^2*sin(x)^2+b^2*cos(x)^2)) |

151 | ellip *=2 |

152 | ellip = ellip^2 |

153 | Integrate/T ellip |

154 | |

155 | return(ellip[99]*2/pi) |

156 | End |

157 | |

158 | //wrapper to calculate the smeared model as an AAO-Struct |

159 | // fills the struct and calls the ususal function with the STRUCT parameter |

160 | // |

161 | // used only for the dependency, not for fitting |

162 | // |

163 | Function fSmearedFlexCyl_Ellip(coefW,yW,xW) |

164 | Wave coefW,yW,xW |

165 | |

166 | String str = getWavesDataFolder(yW,0) |

167 | String DF="root:"+str+":" |

168 | |

169 | WAVE resW = $(DF+str+"_res") |

170 | |

171 | STRUCT ResSmearAAOStruct fs |

172 | WAVE fs.coefW = coefW |

173 | WAVE fs.yW = yW |

174 | WAVE fs.xW = xW |

175 | WAVE fs.resW = resW |

176 | |

177 | Variable err |

178 | err = SmearedFlexCyl_Ellip(fs) |

179 | |

180 | return (0) |

181 | End |

182 | |

183 | // this is all there is to the smeared calculation! |

184 | Function SmearedFlexCyl_Ellip(s) :FitFunc |

185 | Struct ResSmearAAOStruct &s |

186 | |

187 | // the name of your unsmeared model (AAO) is the first argument |

188 | Smear_Model_20(FlexCyl_Ellip,s.coefW,s.xW,s.yW,s.resW) |

189 | |

190 | return(0) |

191 | End |

192 |

**Note:**See TracBrowser for help on using the repository browser.