Changeset 51ec7e8 in sasmodels
- Timestamp:
- Jul 18, 2016 4:54:39 PM (8 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 263daec
- Parents:
- ce176ca
- Location:
- sasmodels
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/compare.py
r256dfe1 r51ec7e8 407 407 composition_type, parts = model_info.composition 408 408 if composition_type == 'product': 409 P, S = [get_model (revert_name(p)) for p in parts]409 P, S = [get_model_class(revert_name(p))() for p in parts] 410 410 model = [MultiplicationModel(P, S)] 411 411 else: -
sasmodels/convert.json
r256dfe1 r51ec7e8 600 600 ], 601 601 "rpa": [ 602 "RPAModel", 603 { 602 "RPA10Model", 603 { 604 "K12": "Kab", "K13": "Kac", "K14": "Kad", 605 "K23": "Kbc", "K24": "Kbd", "K34": "Kcd", 604 606 "N1": "Na", "N2": "Nb", "N3": "Nc", "N4": "Nd", 605 607 "L1": "La", "L2": "Lb", "L3": "Lc", "L4": "Ld", -
sasmodels/convert.py
r4a21b121 r51ec7e8 176 176 newid = p.id 177 177 oldid = translation.get(p.id, p.id) 178 del translation[newid]178 translation.pop(newid, None) 179 179 for k in range(1, p.length+1): 180 translation[newid+str(k)] = oldid+str(k) 180 if newid+str(k) not in translation: 181 translation[newid+str(k)] = oldid+str(k) 181 182 # Remove control parameter from the result 182 183 if model_info.control: … … 211 212 else: 212 213 translation = _get_translation_table(model_info) 213 oldpars = _revert_pars(_unscale_sld(pars), translation)214 oldpars = _trim_vectors(model_info, pars, oldpars)214 oldpars = _revert_pars(_unscale_sld(pars), translation) 215 oldpars = _trim_vectors(model_info, pars, oldpars) 215 216 216 217 … … 246 247 for p in "L1", "L2", "L3", "L4": 247 248 if p in oldpars: oldpars[p] *= 1e-13 249 if pars['case_num'] < 2: 250 for k in ("a", "b"): 251 for p in ("L", "N", "Phi", "b", "v"): 252 oldpars.pop(p+k, None) 253 for k in "Kab,Kac,Kad,Kbc,Kbd".split(','): 254 oldpars.pop(k, None) 255 elif pars['case_num'] < 5: 256 for k in ("a",): 257 for p in ("L", "N", "Phi", "b", "v"): 258 oldpars.pop(p+k, None) 259 for k in "Kab,Kac,Kad".split(','): 260 oldpars.pop(k, None) 248 261 elif name == 'core_shell_parallelepiped': 249 262 _remove_pd(oldpars, 'rimA', name) -
sasmodels/models/rpa.c
r639c4e3 r51ec7e8 6 6 7 7 double Iq(double q, double case_num, 8 double N[], double Phi[], double v[], double L[], double b[], 9 double Kab, double Kac, double Kad, 8 double N[], // DEGREE OF POLYMERIZATION 9 double Phi[], // VOL FRACTION 10 double v[], // SPECIFIC VOLUME 11 double L[], // SCATT. LENGTH 12 double b[], // SEGMENT LENGTH 13 double Kab, double Kac, double Kad, // CHI PARAM 10 14 double Kbc, double Kbd, double Kcd 11 ) { 15 ) 16 { 12 17 int icase = (int)case_num; 13 18 14 #if 0 // Sasview defaults 19 double Nab,Nac,Nad,Nbc,Nbd,Ncd; 20 double Phiab,Phiac,Phiad,Phibc,Phibd,Phicd; 21 double vab,vac,vad,vbc,vbd,vcd; 22 double m; 23 double Xa,Xb,Xc,Xd; 24 double Paa,S0aa,Pab,S0ab,Pac,S0ac,Pad,S0ad; 25 double S0ba,Pbb,S0bb,Pbc,S0bc,Pbd,S0bd; 26 double S0ca,S0cb,Pcc,S0cc,Pcd,S0cd; 27 double S0da,S0db,S0dc,Pdd,S0dd; 28 double Kaa,Kbb,Kcc,Kdd; 29 double Kba,Kca,Kda,Kcb,Kdb,Kdc; 30 double Zaa,Zab,Zac,Zba,Zbb,Zbc,Zca,Zcb,Zcc; 31 double DenT,T11,T12,T13,T21,T22,T23,T31,T32,T33; 32 double Y1,Y2,Y3,X11,X12,X13,X21,X22,X23,X31,X32,X33; 33 double ZZ,DenQ1,DenQ2,DenQ3,DenQ,Q11,Q12,Q13,Q21,Q22,Q23,Q31,Q32,Q33; 34 double N11,N12,N13,N21,N22,N23,N31,N32,N33; 35 double M11,M12,M13,M21,M22,M23,M31,M32,M33; 36 double S11,S12,S13,S14,S21,S22,S23,S24; 37 double S31,S32,S33,S34,S41,S42,S43,S44; 38 double Lad,Lbd,Lcd,Nav,Intg; 39 40 //icase was shifted to N-1 from the original code 41 if (icase <= 1){ 42 Phi[0] = Phi[1] = 0.0000001; 43 N[0] = N[1] = 1000.0; 44 L[0] = L[1] = 1.e-12; 45 v[0] = v[1] = 100.0; 46 b[0] = b[1] = 5.0; 47 Kab = Kac = Kad = Kbc = Kbd = -0.0004; 48 } 49 else if ((icase > 1) && (icase <= 4)){ 50 Phi[0] = 0.0000001; 51 N[0] = 1000.0; 52 L[0] = 1.e-12; 53 v[0] = 100.0; 54 b[0] = 5.0; 55 Kab = Kac = Kad = -0.0004; 56 } 57 58 Nab=sqrt(N[0]*N[1]); 59 Nac=sqrt(N[0]*N[2]); 60 Nad=sqrt(N[0]*N[3]); 61 Nbc=sqrt(N[1]*N[2]); 62 Nbd=sqrt(N[1]*N[3]); 63 Ncd=sqrt(N[2]*N[3]); 64 65 vab=sqrt(v[0]*v[1]); 66 vac=sqrt(v[0]*v[2]); 67 vad=sqrt(v[0]*v[3]); 68 vbc=sqrt(v[1]*v[2]); 69 vbd=sqrt(v[1]*v[3]); 70 vcd=sqrt(v[2]*v[3]); 71 72 Phiab=sqrt(Phi[0]*Phi[1]); 73 Phiac=sqrt(Phi[0]*Phi[2]); 74 Phiad=sqrt(Phi[0]*Phi[3]); 75 Phibc=sqrt(Phi[1]*Phi[2]); 76 Phibd=sqrt(Phi[1]*Phi[3]); 77 Phicd=sqrt(Phi[2]*Phi[3]); 78 79 Xa=q*q*b[0]*b[0]*N[0]/6.0; 80 Xb=q*q*b[1]*b[1]*N[1]/6.0; 81 Xc=q*q*b[2]*b[1]*N[2]/6.0; // PAK: not b2*b2? 82 Xd=q*q*b[3]*b[1]*N[3]/6.0; // PAK: not b3*b3? 83 84 Paa=2.0*(exp(-Xa)-1.0+Xa)/(Xa*Xa); 85 S0aa=N[0]*Phi[0]*v[0]*Paa; 86 Pab=((1.0-exp(-Xa))/Xa)*((1.0-exp(-Xb))/Xb); 87 S0ab=(Phiab*vab*Nab)*Pab; 88 Pac=((1.0-exp(-Xa))/Xa)*exp(-Xb)*((1.0-exp(-Xc))/Xc); 89 S0ac=(Phiac*vac*Nac)*Pac; 90 Pad=((1.0-exp(-Xa))/Xa)*exp(-Xb-Xc)*((1.0-exp(-Xd))/Xd); 91 S0ad=(Phiad*vad*Nad)*Pad; 92 93 S0ba=S0ab; 94 Pbb=2.0*(exp(-Xb)-1.0+Xb)/(Xb*Xb); 95 S0bb=N[1]*Phi[1]*v[1]*Pbb; 96 Pbc=((1.0-exp(-Xb))/Xb)*((1.0-exp(-Xc))/Xc); 97 S0bc=(Phibc*vbc*Nbc)*Pbc; 98 Pbd=((1.0-exp(-Xb))/Xb)*exp(-Xc)*((1.0-exp(-Xd))/Xd); 99 S0bd=(Phibd*vbd*Nbd)*Pbd; 100 101 S0ca=S0ac; 102 S0cb=S0bc; 103 Pcc=2.0*(exp(-Xc)-1.0+Xc)/(Xc*Xc); 104 S0cc=N[2]*Phi[2]*v[2]*Pcc; 105 Pcd=((1.0-exp(-Xc))/Xc)*((1.0-exp(-Xd))/Xd); 106 S0cd=(Phicd*vcd*Ncd)*Pcd; 107 108 S0da=S0ad; 109 S0db=S0bd; 110 S0dc=S0cd; 111 Pdd=2.0*(exp(-Xd)-1.0+Xd)/(Xd*Xd); 112 S0dd=N[3]*Phi[3]*v[3]*Pdd; 113 //icase was shifted to N-1 from the original code 114 switch(icase){ 115 case 0: 116 S0aa=0.000001; 117 S0ab=0.000002; 118 S0ac=0.000003; 119 S0ad=0.000004; 120 S0bb=0.000005; 121 S0bc=0.000006; 122 S0bd=0.000007; 123 S0cd=0.000008; 124 break; 125 case 1: 126 S0aa=0.000001; 127 S0ab=0.000002; 128 S0ac=0.000003; 129 S0ad=0.000004; 130 S0bb=0.000005; 131 S0bc=0.000006; 132 S0bd=0.000007; 133 break; 134 case 2: 135 S0aa=0.000001; 136 S0ab=0.000002; 137 S0ac=0.000003; 138 S0ad=0.000004; 139 S0bc=0.000005; 140 S0bd=0.000006; 141 S0cd=0.000007; 142 break; 143 case 3: 144 S0aa=0.000001; 145 S0ab=0.000002; 146 S0ac=0.000003; 147 S0ad=0.000004; 148 S0bc=0.000005; 149 S0bd=0.000006; 150 break; 151 case 4: 152 S0aa=0.000001; 153 S0ab=0.000002; 154 S0ac=0.000003; 155 S0ad=0.000004; 156 break; 157 case 5: 158 S0ab=0.000001; 159 S0ac=0.000002; 160 S0ad=0.000003; 161 S0bc=0.000004; 162 S0bd=0.000005; 163 S0cd=0.000006; 164 break; 165 case 6: 166 S0ab=0.000001; 167 S0ac=0.000002; 168 S0ad=0.000003; 169 S0bc=0.000004; 170 S0bd=0.000005; 171 break; 172 case 7: 173 S0ab=0.000001; 174 S0ac=0.000002; 175 S0ad=0.000003; 176 break; 177 case 8: 178 S0ac=0.000001; 179 S0ad=0.000002; 180 S0bc=0.000003; 181 S0bd=0.000004; 182 break; 183 default : //case 9: 184 break; 185 } 186 S0ba=S0ab; 187 S0ca=S0ac; 188 S0cb=S0bc; 189 S0da=S0ad; 190 S0db=S0bd; 191 S0dc=S0cd; 192 193 Kaa=0.0; 194 Kbb=0.0; 195 Kcc=0.0; 196 Kdd=0.0; 197 198 Kba=Kab; 199 Kca=Kac; 200 Kcb=Kbc; 201 Kda=Kad; 202 Kdb=Kbd; 203 Kdc=Kcd; 204 205 Zaa=Kaa-Kad-Kad; 206 Zab=Kab-Kad-Kbd; 207 Zac=Kac-Kad-Kcd; 208 Zba=Kba-Kbd-Kad; 209 Zbb=Kbb-Kbd-Kbd; 210 Zbc=Kbc-Kbd-Kcd; 211 Zca=Kca-Kcd-Kad; 212 Zcb=Kcb-Kcd-Kbd; 213 Zcc=Kcc-Kcd-Kcd; 214 215 DenT=(-(S0ac*S0bb*S0ca) + S0ab*S0bc*S0ca + S0ac*S0ba*S0cb - S0aa*S0bc*S0cb - S0ab*S0ba*S0cc + S0aa*S0bb*S0cc); 216 217 T11= (-(S0bc*S0cb) + S0bb*S0cc)/DenT; 218 T12= (S0ac*S0cb - S0ab*S0cc)/DenT; 219 T13= (-(S0ac*S0bb) + S0ab*S0bc)/DenT; 220 T21= (S0bc*S0ca - S0ba*S0cc)/DenT; 221 T22= (-(S0ac*S0ca) + S0aa*S0cc)/DenT; 222 T23= (S0ac*S0ba - S0aa*S0bc)/DenT; 223 T31= (-(S0bb*S0ca) + S0ba*S0cb)/DenT; 224 T32= (S0ab*S0ca - S0aa*S0cb)/DenT; 225 T33= (-(S0ab*S0ba) + S0aa*S0bb)/DenT; 226 227 Y1=T11*S0ad+T12*S0bd+T13*S0cd+1.0; 228 Y2=T21*S0ad+T22*S0bd+T23*S0cd+1.0; 229 Y3=T31*S0ad+T32*S0bd+T33*S0cd+1.0; 230 231 X11=Y1*Y1; 232 X12=Y1*Y2; 233 X13=Y1*Y3; 234 X21=Y2*Y1; 235 X22=Y2*Y2; 236 X23=Y2*Y3; 237 X31=Y3*Y1; 238 X32=Y3*Y2; 239 X33=Y3*Y3; 240 241 ZZ=S0ad*(T11*S0ad+T12*S0bd+T13*S0cd)+S0bd*(T21*S0ad+T22*S0bd+T23*S0cd)+S0cd*(T31*S0ad+T32*S0bd+T33*S0cd); 242 243 m=1.0/(S0dd-ZZ); 244 245 N11=m*X11+Zaa; 246 N12=m*X12+Zab; 247 N13=m*X13+Zac; 248 N21=m*X21+Zba; 249 N22=m*X22+Zbb; 250 N23=m*X23+Zbc; 251 N31=m*X31+Zca; 252 N32=m*X32+Zcb; 253 N33=m*X33+Zcc; 254 255 M11= N11*S0aa + N12*S0ab + N13*S0ac; 256 M12= N11*S0ab + N12*S0bb + N13*S0bc; 257 M13= N11*S0ac + N12*S0bc + N13*S0cc; 258 M21= N21*S0aa + N22*S0ab + N23*S0ac; 259 M22= N21*S0ab + N22*S0bb + N23*S0bc; 260 M23= N21*S0ac + N22*S0bc + N23*S0cc; 261 M31= N31*S0aa + N32*S0ab + N33*S0ac; 262 M32= N31*S0ab + N32*S0bb + N33*S0bc; 263 M33= N31*S0ac + N32*S0bc + N33*S0cc; 264 265 DenQ1=1.0+M11-M12*M21+M22+M11*M22-M13*M31-M13*M22*M31; 266 DenQ2= M12*M23*M31+M13*M21*M32-M23*M32-M11*M23*M32+M33+M11*M33; 267 DenQ3= -M12*M21*M33+M22*M33+M11*M22*M33; 268 DenQ=DenQ1+DenQ2+DenQ3; 269 270 Q11= (1.0 + M22-M23*M32 + M33 + M22*M33)/DenQ; 271 Q12= (-M12 + M13*M32 - M12*M33)/DenQ; 272 Q13= (-M13 - M13*M22 + M12*M23)/DenQ; 273 Q21= (-M21 + M23*M31 - M21*M33)/DenQ; 274 Q22= (1.0 + M11 - M13*M31 + M33 + M11*M33)/DenQ; 275 Q23= (M13*M21 - M23 - M11*M23)/DenQ; 276 Q31= (-M31 - M22*M31 + M21*M32)/DenQ; 277 Q32= (M12*M31 - M32 - M11*M32)/DenQ; 278 Q33= (1.0 + M11 - M12*M21 + M22 + M11*M22)/DenQ; 279 280 S11= Q11*S0aa + Q21*S0ab + Q31*S0ac; 281 S12= Q12*S0aa + Q22*S0ab + Q32*S0ac; 282 S13= Q13*S0aa + Q23*S0ab + Q33*S0ac; 283 S14=-S11-S12-S13; 284 S21= Q11*S0ba + Q21*S0bb + Q31*S0bc; 285 S22= Q12*S0ba + Q22*S0bb + Q32*S0bc; 286 S23= Q13*S0ba + Q23*S0bb + Q33*S0bc; 287 S24=-S21-S22-S23; 288 S31= Q11*S0ca + Q21*S0cb + Q31*S0cc; 289 S32= Q12*S0ca + Q22*S0cb + Q32*S0cc; 290 S33= Q13*S0ca + Q23*S0cb + Q33*S0cc; 291 S34=-S31-S32-S33; 292 S41=S14; 293 S42=S24; 294 S43=S34; 295 S44=S11+S22+S33+2.0*S12+2.0*S13+2.0*S23; 296 297 Nav=6.022045e+23; 298 Lad=(L[0]/v[0]-L[3]/v[3])*sqrt(Nav); 299 Lbd=(L[1]/v[1]-L[3]/v[3])*sqrt(Nav); 300 Lcd=(L[2]/v[2]-L[3]/v[3])*sqrt(Nav); 301 302 Intg=Lad*Lad*S11+Lbd*Lbd*S22+Lcd*Lcd*S33+2.0*Lad*Lbd*S12+2.0*Lbd*Lcd*S23+2.0*Lad*Lcd*S13; 303 304 return Intg; 305 306 307 /* Attempts at a new implementation --- supressed for now 308 #if 1 // Sasview defaults 15 309 if (icase <= 1) { 16 310 N[0]=N[1]=1000.0; 17 311 Phi[0]=Phi[1]=0.0000001; 18 312 Kab=Kac=Kad=Kbc=Kbd=-0.0004; 19 L a=Lb=1.0e-12;20 v a=vb=100.0;21 b a=bb=5.0;313 L[0]=L[1]=1.0e-12; 314 v[0]=v[1]=100.0; 315 b[0]=b[1]=5.0; 22 316 } else if (icase <= 4) { 23 317 Phi[0]=0.0000001; 24 318 Kab=Kac=Kad=-0.0004; 25 L a=1.0e-12;26 v a=100.0;27 b a=5.0;319 L[0]=1.0e-12; 320 v[0]=100.0; 321 b[0]=5.0; 28 322 } 29 323 #else … … 297 591 298 592 return result; 299 593 */ 300 594 } -
sasmodels/models/rpa.py
rce176ca r51ec7e8 69 69 See details in the model function help 70 70 """ 71 category = " "71 category = "shape-independent" 72 72 73 73 CASES = [ … … 102 102 ] 103 103 104 category = "shape-independent"105 104 106 105 source = ["rpa.c"] 106 single = False 107 107 108 108 control = "case_num"
Note: See TracChangeset
for help on using the changeset viewer.