Changeset 931 for sans/Dev/trunk/NCNR_User_Procedures
 Timestamp:
 Feb 3, 2014 3:36:30 PM (9 years ago)
 Location:
 sans/Dev/trunk/NCNR_User_Procedures/Analysis/Models
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

sans/Dev/trunk/NCNR_User_Procedures/Analysis/Models/NewModels_2010/Two_Yukawa_v40.ipf
r824 r931 26 26 // conversion to Igor from the ccode was not terribly painful, and very useful for debugging. 27 27 // 28 // 29 // JAN 2014 SRK  added code to enforce Z1 > Z2. If this condition is not met, then the calculation will 30 // return a solution, but it will be incorrect (the result will look like a valid structure factor, but be incorrect) 31 // This condition is necessary due to the asymmetric treatment of these parameters in the mathematics of the calculation 32 // by Yun Liu. A lower limit constraint has been added (automatically) so that the condition will be met while fitting 33 //  without this constraint, parameter "flips" will confound the optimization. This LoLim wave only been added to the 34 // calculation of S(Q), not any combination PS functions. 35 //  This, unfortunately means that all of the "_Sq" macros *MAY* need to be updated to reflect this constraint 36 // so it will actually be enforced during fitting. I think I'll note this in the manual, and see if the fitting can 37 // handle this. If it can't. I'll instruct users to add a LoLim to the Z1, and this should take care of this issue 38 // Otherwise I may just introduce more problems by programmatically enforcing "hidden" constraints, and have a lot more 39 // code to maintain if the constraints are not quite correct in all situations. 40 // 41 // JAN 2014  added code to bypass the condition Z1 == Z2, which is also diallowed in Yun's code. 42 //  code to prevent K1 == 0 or K2 == 0 was previously in place. 43 // These conditions are all specified in Yun's "Appendix B" for the "TYSQ21 Matlab Package" 28 44 // 29 45 // … … 122 138 Label left "Structure Factor" 123 139 AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 140 141 // make a constraint wave appropriate for the Z1 > Z2 condition for fitting 142 // setting the lower bound on Z1 (> Z2) is sufficient to meet this condition 143 // and check the box on the panel so that constraints are used 144 Duplicate/O parameters_2yuk Lolim_2yuk 145 LoLim_2yuk = "" 146 LoLim_2yuk[3] = "K5" 147 148 CheckBox check_2,win=wrapperPanel,value= 1 149 124 150 125 151 AddModelToStrings("TwoYukawa","coef_2yuk","parameters_2yuk","2yuk") … … 129 155 130 156 //AAO version 157 // 131 158 Function TwoYukawa(cw,yw,xw) : FitFunc 132 159 Wave cw,yw,xw 133 160 161 // make sure that none of the values are too close to zero 162 // make them very small instead 134 163 if(abs(cw[2]) < 0.001) 135 164 cw[2] = 0.001 … … 143 172 if(abs(cw[5]) < 0.001) 144 173 cw[5] = 0.001 174 endif 175 176 if(cw[3] == cw[5]) // Z1 == Z2 not allowed, this may not be enough of a correction 177 cw[3] *= 1.001 178 endif 179 180 // JAN 2014  SRK 181 // if I do a swap on cw, then the values on the table "flip" and is very unnatural 182 //  but it may be OK. Alternatively, I could create a tmp wave to pass through into the calculation. 183 184 185 // then make sure that Z1 > Z2 is true 186 // swap 1 and 2 if needed 187 Variable tmp 188 if(cw[5] > cw[3]) 189 //swap the K values 190 tmp = cw[2] 191 cw[2] = cw[4] 192 cw[4] = tmp 193 // then the Z values 194 tmp = cw[3] 195 cw[3] = cw[5] 196 cw[5] = tmp 145 197 endif 146 198 … … 639 691 t5 = (8.*m32*m44*Z1 + m32*m44*(8. + 3.*Z1)*Z2 + (3.*m32*m44  4.*(m14*(m32 + 3.*m41  2.*m42) + m44)*Z1)*pow(Z2,2) + m34*(Z1 + Z2)*t3 + 2.*m31*(Z1 + Z2)*t4  4.*m14*m32*pow(Z2,3)) 640 692 641 TY_qc123 = (2.*phi*pow(Z2,2)*(9.*t1 + 4.*(2.*m44*Z1 + m34*(Z1 + Z2))*pow(m11,2)*pow(Z2,2)  3.*m24*t2  6.*m11*t5)*pow(Z1 + Z2,1))/3. ;693 TY_qc123 = (2.*phi*pow(Z2,2)*(9.*t1 + 4.*(2.*m44*Z1 + m34*(Z1 + Z2))*pow(m11,2)*pow(Z2,2)  3.*m24*t2  6.*m11*t5)*pow(Z1 + Z2,1))/3. 642 694 643 695 … … 647 699 t4 = (4.*(3.*m31  2.*m32)*m44 + Z1*(4.*m31*m44 + 3.*m32*m44  2.*(m14*(6.*m31 + 4.*m32 + 3.*m41  2.*m42) + m44)*Z1) + m34*(m42*(8.  3.*Z1) + 4.*m41*(3. + Z1) + 4.*pow(Z1,2))) 648 700 649 TY_qc132 = (2.*phi*pow(Z1,2)*(9.*t1 + 4.*(2.*m34*Z2 + m44*(Z1 + Z2))*pow(m11,2)*pow(Z1,2) + 3.*m24*t2 + 6.*m11*(Z1*t3 + Z2*t4))*pow(Z1 + Z2,1))/3. ;701 TY_qc132 = (2.*phi*pow(Z1,2)*(9.*t1 + 4.*(2.*m34*Z2 + m44*(Z1 + Z2))*pow(m11,2)*pow(Z1,2) + 3.*m24*t2 + 6.*m11*(Z1*t3 + Z2*t4))*pow(Z1 + Z2,1))/3. 650 702 651 703 … … 714 766 t2 = (exp(2*Z1)*t1  TY_qc112*(Z1 + Z2)*pow(Z1,2) + 2*(Z1 + Z2)*exp(Z1)*(TY_qa12 + (TY_qa12 + TY_qb12)*Z1 + TY_qc112*pow(Z1,2))) 715 767 716 TY_A12 = 6*phi*TY_qc112*exp(2*Z1  Z2)*pow(TY_q22,2)*pow(Z1,3)*(2*TY_qc212*exp(Z1)*(Z2 + (Z1 + Z2)*exp(Z1))*pow(Z1,2) + exp(Z2)*t2)*pow(Z1 + Z2,1) ;768 TY_A12 = 6*phi*TY_qc112*exp(2*Z1  Z2)*pow(TY_q22,2)*pow(Z1,3)*(2*TY_qc212*exp(Z1)*(Z2 + (Z1 + Z2)*exp(Z1))*pow(Z1,2) + exp(Z2)*t2)*pow(Z1 + Z2,1) 717 769 718 770 … … 721 773 t3 = (2*(TY_qa12*TY_qc121 + TY_qa21*TY_qc112*(1 + Z1) + Z1*t2)*(Z1 + Z2)*exp(Z1) + exp(2*Z1)*t1  2*TY_qc112*TY_qc121*(Z1 + Z2)*pow(Z1,2)) 722 774 723 TY_A21 = 6*phi*exp(2*Z1  Z2)*pow(TY_q22,2)*pow(Z1,3)*(2*(TY_qc121*TY_qc212 + TY_qc112*TY_qc221)*exp(Z1)*(Z2 + (Z1 + Z2)*exp(Z1))*pow(Z1,2) + exp(Z2)*t3)*pow(Z1 + Z2,1) ;775 TY_A21 = 6*phi*exp(2*Z1  Z2)*pow(TY_q22,2)*pow(Z1,3)*(2*(TY_qc121*TY_qc212 + TY_qc112*TY_qc221)*exp(Z1)*(Z2 + (Z1 + Z2)*exp(Z1))*pow(Z1,2) + exp(Z2)*t3)*pow(Z1 + Z2,1) 724 776 725 777 … … 728 780 t3 = (12*phi*(TY_qa12*TY_qc122 + TY_qa22*TY_qc112*(1 + Z1) + Z1*t1)*(Z1 + Z2)*exp(Z1)  2*phi*TY_qc112*TY_qc122*(Z1 + Z2)*pow(Z1,2) + exp(2*Z1)*(6*phi*t2 + TY_q22*TY_qc112*(Z1 + Z2)*pow(Z1,3))) 729 781 730 TY_A22 = exp(2*Z1  Z2)*pow(TY_q22,2)*pow(Z1,3)*(12*phi*(TY_qc122*TY_qc212 + TY_qc112*TY_qc222)*exp(Z1)*(Z2 + (Z1 + Z2)*exp(Z1))*pow(Z1,2) + exp(Z2)*t3)*pow(Z1 + Z2,1) ;782 TY_A22 = exp(2*Z1  Z2)*pow(TY_q22,2)*pow(Z1,3)*(12*phi*(TY_qc122*TY_qc212 + TY_qc112*TY_qc222)*exp(Z1)*(Z2 + (Z1 + Z2)*exp(Z1))*pow(Z1,2) + exp(Z2)*t3)*pow(Z1 + Z2,1) 731 783 732 784 … … 735 787 t3 = (2*Z1*(TY_qb23*TY_qc112*(1 + Z1)*(Z1 + Z2) + TY_qb12*TY_qc123*(1 + Z1)*(Z1 + Z2)  Z1*t1) + TY_qa23*TY_qc112*(Z1 + Z2)*(2 + pow(Z1,2)) + TY_qa12*TY_qc123*(Z1 + Z2)*(2 + pow(Z1,2))) 736 788 737 TY_A23 = 6*phi*exp(2*Z1  Z2)*pow(TY_q22,2)*pow(Z1,3)*(2*(TY_qc123*TY_qc212 + TY_qc112*TY_qc223)*exp(Z1)*(Z2 + (Z1 + Z2)*exp(Z1))*pow(Z1,2) + exp(Z2)*(2*t2*(Z1 + Z2)*exp(Z1) + exp(2*Z1)*t3  2*TY_qc112*TY_qc123*(Z1 + Z2)*pow(Z1,2)))*pow(Z1 + Z2,1) ;789 TY_A23 = 6*phi*exp(2*Z1  Z2)*pow(TY_q22,2)*pow(Z1,3)*(2*(TY_qc123*TY_qc212 + TY_qc112*TY_qc223)*exp(Z1)*(Z2 + (Z1 + Z2)*exp(Z1))*pow(Z1,2) + exp(Z2)*(2*t2*(Z1 + Z2)*exp(Z1) + exp(2*Z1)*t3  2*TY_qc112*TY_qc123*(Z1 + Z2)*pow(Z1,2)))*pow(Z1 + Z2,1) 738 790 739 791 … … 749 801 t10 = (12*phi*(TY_qa23*TY_qc121 + TY_qa22*TY_qc122 + TY_qa21*TY_qc123 + TY_qa12*TY_qc132 + TY_qa32*TY_qc112*(1 + Z1) + Z1*t1)*(Z1 + Z2)*exp(Z1 + Z2)  12*phi*t2*Z2*exp(Z1)*pow(Z1,2) + 12*phi*t3*(Z1 + Z2)*exp(2*Z1)*pow(Z1,2)  6*phi*(Z1 + Z2)*exp(Z2)*t4*pow(Z1,2) + exp(2*Z1 + Z2)*(TY_q22*t5 + 6*phi*t9)) 750 802 751 TY_A32 = exp(2*Z1  Z2)*pow(TY_q22,2)*pow(Z1,3)*t10*pow(Z1 + Z2,1) ;803 TY_A32 = exp(2*Z1  Z2)*pow(TY_q22,2)*pow(Z1,3)*t10*pow(Z1 + Z2,1) 752 804 753 805 … … 757 809 t4 = (2*(TY_qa32*TY_qc121 + TY_qa21*(TY_q22 + TY_qc132))  2*(TY_qb32*TY_qc121 + TY_qb21*(TY_q22 + TY_qc132))*Z1 + (TY_qa32*TY_qc121 + 2*TY_qb32*TY_qc121 + TY_qa21*TY_qc132 + 2*TY_qb21*TY_qc132  2*TY_qc121*TY_qc132 + TY_q22*(TY_qa21 + 2*TY_qb21  2*TY_qc121  2*TY_qc221)  2*TY_qc132*TY_qc221  2*TY_qc121*TY_qc232)*pow(Z1,2)) 758 810 759 TY_A41 = 6*phi*exp(2*Z1  Z2)*pow(TY_q22,2)*pow(Z1,3)*(2*exp(Z1)*t1*pow(Z1,2) + exp(Z2)*(2*t2*(Z1 + Z2)*exp(Z1)  2*TY_qc121*TY_qc132*(Z1 + Z2)*pow(Z1,2) + exp(2*Z1)*(Z2*t3 + Z1*t4)))*pow(Z1 + Z2,1) ;811 TY_A41 = 6*phi*exp(2*Z1  Z2)*pow(TY_q22,2)*pow(Z1,3)*(2*exp(Z1)*t1*pow(Z1,2) + exp(Z2)*(2*t2*(Z1 + Z2)*exp(Z1)  2*TY_qc121*TY_qc132*(Z1 + Z2)*pow(Z1,2) + exp(2*Z1)*(Z2*t3 + Z1*t4)))*pow(Z1 + Z2,1) 760 812 761 813 … … 767 819 t6 = (12*phi*(TY_qa22*TY_qc132 + TY_qa32*TY_qc122*(1 + Z1) + Z1*t1)*(Z1 + Z2)*exp(Z1 + Z2)  12*phi*t2*Z2*exp(Z1)*pow(Z1,2) + 12*phi*t3*(Z1 + Z2)*exp(2*Z1)*pow(Z1,2)  12*phi*TY_qc122*TY_qc132*(Z1 + Z2)*exp(Z2)*pow(Z1,2) + exp(2*Z1 + Z2)*t5) 768 820 769 TY_A42 = exp(2*Z1  Z2)*pow(TY_q22,2)*pow(Z1,3)*t6*pow(Z1 + Z2,1) ;821 TY_A42 = exp(2*Z1  Z2)*pow(TY_q22,2)*pow(Z1,3)*t6*pow(Z1 + Z2,1) 770 822 771 823 … … 775 827 t4 = (2*TY_qa32*TY_qc123 + 2*TY_qa23*(TY_q22 + TY_qc132) + 2*(TY_qb32*TY_qc123 + TY_qb23*(TY_q22 + TY_qc132))*Z1 + ((TY_qa32*TY_qc123)  (TY_qa23 + 2*TY_qb23)*TY_qc132 + TY_q22*(TY_qa23 + 2*(TY_qb23 + TY_qc123 + TY_qc132 + TY_qc223)) + 2*((TY_qb32*TY_qc123) + TY_qc132*(TY_qc123 + TY_qc223) + TY_qc123*TY_qc232) + 2*pow(TY_q22,2))*pow(Z1,2)) 776 828 777 TY_A43 = 6*phi*exp(2*Z1  Z2)*pow(TY_q22,2)*pow(Z1,3)*(2*exp(Z1)*t1*pow(Z1,2) + exp(Z2)*(2*t2*(Z1 + Z2)*exp(Z1) + 2*TY_qc123*TY_qc132*(Z1 + Z2)*pow(Z1,2) + exp(2*Z1)*(Z2*t3 + Z1*t4)))*pow(Z1 + Z2,1) ;829 TY_A43 = 6*phi*exp(2*Z1  Z2)*pow(TY_q22,2)*pow(Z1,3)*(2*exp(Z1)*t1*pow(Z1,2) + exp(Z2)*(2*t2*(Z1 + Z2)*exp(Z1) + 2*TY_qc123*TY_qc132*(Z1 + Z2)*pow(Z1,2) + exp(2*Z1)*(Z2*t3 + Z1*t4)))*pow(Z1 + Z2,1) 778 830 779 831 … … 782 834 t3 = ((TY_q22 + TY_qc132)*exp(2*Z1)*t2 + (Z1 + Z2)*pow(TY_qc132,2)*pow(Z1,2)  2*TY_qc132*(Z1 + Z2)*exp(Z1)*(TY_qa32 + (TY_qa32 + TY_qb32)*Z1 + (TY_q22 + TY_qc132)*pow(Z1,2))) 783 835 784 TY_A52 = 6*phi*exp(2*Z1  Z2)*pow(TY_q22,2)*pow(Z1,3)*(2*TY_qc232*exp(Z1)*t1*pow(Z1,2) + exp(Z2)*t3)*pow(Z1 + Z2,1) ;836 TY_A52 = 6*phi*exp(2*Z1  Z2)*pow(TY_q22,2)*pow(Z1,3)*(2*TY_qc232*exp(Z1)*t1*pow(Z1,2) + exp(Z2)*t3)*pow(Z1 + Z2,1) 785 837 786 838 … … 834 886 t4 = (exp(Z1)*(2*Z2*t3 + TY_qa21*TY_qc212*(Z1 + Z2)*(2 + pow(Z2,2)) + TY_qa12*TY_qc221*(Z1 + Z2)*(2 + pow(Z2,2))) + 2*(TY_qc121*TY_qc212 + TY_qc112*TY_qc221)*(Z1 + Z2)*pow(Z2,2)) 835 887 836 TY_B12 = 6*phi*exp(Z1  2*Z2)*pow(TY_q22,2)*pow(Z2,3)*(2*TY_qc212*TY_qc221*(Z1 + Z2)*exp(Z1)*pow(Z2,2) + 2*exp(Z2)*((Z1 + Z2)*t1*exp(Z1) + t2*Z1*pow(Z2,2)) + exp(2*Z2)*t4)*pow(Z1 + Z2,1) ;888 TY_B12 = 6*phi*exp(Z1  2*Z2)*pow(TY_q22,2)*pow(Z2,3)*(2*TY_qc212*TY_qc221*(Z1 + Z2)*exp(Z1)*pow(Z2,2) + 2*exp(Z2)*((Z1 + Z2)*t1*exp(Z1) + t2*Z1*pow(Z2,2)) + exp(2*Z2)*t4)*pow(Z1 + Z2,1) 837 889 838 890 … … 846 898 t6 = (TY_q22*(TY_qa12 + 2*TY_qb12  2*TY_qc112  2*TY_qc212) + TY_qc212*(TY_qa23 + 2*TY_qb23  2*TY_qc123  2*TY_qc223) + (TY_qa12 + 2*TY_qb12  2*TY_qc112)*TY_qc223) 847 899 848 TY_B14 = 6*phi*exp(Z1  2*Z2)*pow(TY_q22,2)*pow(Z2,3)*(2*TY_qc212*TY_qc223*(Z1 + Z2)*exp(Z1)*pow(Z2,2) + 2*exp(Z2)*t1 + exp(2*Z2)*(2*t2*(Z1 + Z2)*pow(Z2,2) + exp(Z1)*(2*t3*Z1  2*t4*Z2 + t5*pow(Z2,2) + t6*pow(Z2,3))))*pow(Z1 + Z2,1) ;900 TY_B14 = 6*phi*exp(Z1  2*Z2)*pow(TY_q22,2)*pow(Z2,3)*(2*TY_qc212*TY_qc223*(Z1 + Z2)*exp(Z1)*pow(Z2,2) + 2*exp(Z2)*t1 + exp(2*Z2)*(2*t2*(Z1 + Z2)*pow(Z2,2) + exp(Z1)*(2*t3*Z1  2*t4*Z2 + t5*pow(Z2,2) + t6*pow(Z2,3))))*pow(Z1 + Z2,1) 849 901 850 902 … … 854 906 t3 = ((TY_qc121*Z1*pow(Z2,2)) + (Z1 + Z2)*exp(Z1)*(TY_qa21 + (TY_qa21 + TY_qb21)*Z2 + TY_qc221*pow(Z2,2))) 855 907 856 TY_B21 = 6*phi*TY_qc221*exp(Z1  2*Z2)*pow(TY_q22,2)*pow(Z2,3)*(t1 + exp(2*Z2)*t2 + 2*exp(Z2)*t3)*pow(Z1 + Z2,1) ;908 TY_B21 = 6*phi*TY_qc221*exp(Z1  2*Z2)*pow(TY_q22,2)*pow(Z2,3)*(t1 + exp(2*Z2)*t2 + 2*exp(Z2)*t3)*pow(Z1 + Z2,1) 857 909 858 910 … … 864 916 t5 = (6*phi*(2*Z2*t4 + TY_qa22*TY_qc221*(Z1 + Z2)*(2 + pow(Z2,2)) + TY_qa21*TY_qc222*(Z1 + Z2)*(2 + pow(Z2,2))) + TY_q22*TY_qc221*(Z1 + Z2)*pow(Z2,3)) 865 917 866 TY_B22 = exp(Z1  2*Z2)*pow(TY_q22,2)*pow(Z2,3)*(12*phi*TY_qc221*TY_qc222*(Z1 + Z2)*exp(Z1)*pow(Z2,2) + 12*phi*exp(Z2)*t2 + exp(2*Z2)*(12*phi*t3*(Z1 + Z2)*pow(Z2,2) + exp(Z1)*t5))*pow(Z1 + Z2,1) ;918 TY_B22 = exp(Z1  2*Z2)*pow(TY_q22,2)*pow(Z2,3)*(12*phi*TY_qc221*TY_qc222*(Z1 + Z2)*exp(Z1)*pow(Z2,2) + 12*phi*exp(Z2)*t2 + exp(2*Z2)*(12*phi*t3*(Z1 + Z2)*pow(Z2,2) + exp(Z1)*t5))*pow(Z1 + Z2,1) 867 919 868 920 … … 885 937 t15 = (6*phi*(Z1 + Z2)*exp(Z1)*t1*pow(Z2,2) + 12*phi*exp(Z2)*t13 + exp(2*Z2)*(12*phi*t4*(Z1 + Z2)*pow(Z2,2) + exp(Z1)*(TY_q22*TY_qc222*(Z1 + Z2)*pow(Z2,3)  6*phi*(2*t5*Z1 + 2*t6*Z2  (2*t7 + t8*Z1)*pow(Z2,2)  t14*pow(Z2,3))))) 886 938 887 TY_B23 = exp(Z1  2*Z2)*pow(TY_q22,2)*pow(Z2,3)*t15*pow(Z1 + Z2,1) ;939 TY_B23 = exp(Z1  2*Z2)*pow(TY_q22,2)*pow(Z2,3)*t15*pow(Z1 + Z2,1) 888 940 889 941 … … 895 947 t6 = (12*phi*(Z1 + Z2)*t1*exp(Z1 + Z2)  12*phi*TY_qc222*TY_qc223*(Z1 + Z2)*exp(Z1)*pow(Z2,2)  12*phi*t2*Z1*exp(Z2)*pow(Z2,2) + 12*phi*t3*(Z1 + Z2)*exp(2*Z2)*pow(Z2,2) + exp(Z1 + 2*Z2)*t5) 896 948 897 TY_B24 = exp(Z1  2*Z2)*pow(TY_q22,2)*pow(Z2,3)*t6*pow(Z1 + Z2,1) ;949 TY_B24 = exp(Z1  2*Z2)*pow(TY_q22,2)*pow(Z2,3)*t6*pow(Z1 + Z2,1) 898 950 899 951 … … 901 953 t2 = ((Z1 + Z2)*exp(Z1)*pow(TY_qc223,2)*pow(Z2,2) + (TY_q22 + TY_qc223)*exp(2*Z2)*t1 + 2*TY_qc223*exp(Z2)*(TY_qc123*Z1*pow(Z2,2)  (Z1 + Z2)*exp(Z1)*(TY_qa23 + (TY_qa23 + TY_qb23)*Z2 + (TY_q22 + TY_qc223)*pow(Z2,2)))) 902 954 903 TY_B25 = 6*phi*exp(Z1  2*Z2)*pow(TY_q22,2)*pow(Z2,3)*t2*pow(Z1 + Z2,1) ;955 TY_B25 = 6*phi*exp(Z1  2*Z2)*pow(TY_q22,2)*pow(Z2,3)*t2*pow(Z1 + Z2,1) 904 956 905 957 … … 909 961 t4 = (exp(Z1)*(2*Z2*t3 + TY_qa32*TY_qc221*(Z1 + Z2)*(2 + pow(Z2,2)) + TY_qa21*TY_qc232*(Z1 + Z2)*(2 + pow(Z2,2))) + 2*(TY_qc132*TY_qc221 + TY_qc121*TY_qc232)*(Z1 + Z2)*pow(Z2,2)) 910 962 911 TY_B32 = 6*phi*exp(Z1  2*Z2)*pow(TY_q22,2)*pow(Z2,3)*(2*TY_qc221*TY_qc232*(Z1 + Z2)*exp(Z1)*pow(Z2,2) + 2*exp(Z2)*((Z1 + Z2)*t1*exp(Z1) + t2*Z1*pow(Z2,2)) + exp(2*Z2)*t4)*pow(Z1 + Z2,1) ;963 TY_B32 = 6*phi*exp(Z1  2*Z2)*pow(TY_q22,2)*pow(Z2,3)*(2*TY_qc221*TY_qc232*(Z1 + Z2)*exp(Z1)*pow(Z2,2) + 2*exp(Z2)*((Z1 + Z2)*t1*exp(Z1) + t2*Z1*pow(Z2,2)) + exp(2*Z2)*t4)*pow(Z1 + Z2,1) 912 964 913 965 … … 919 971 t6 = (2*t3*Z1 + 2*t4*Z2  t5*pow(Z2,2) + ((2*TY_q22  TY_qa32  2*TY_qb32 + 2*TY_qc132)*(TY_q22 + TY_qc223) + (2*TY_q22  TY_qa23 + 2*(TY_qb23 + TY_qc123 + TY_qc223))*TY_qc232)*pow(Z2,3)) 920 972 921 TY_B34 = 6*phi*exp(Z1  2*Z2)*pow(TY_q22,2)*pow(Z2,3)*(2*TY_qc223*TY_qc232*(Z1 + Z2)*exp(Z1)*pow(Z2,2) + 2*exp(Z2)*t1 + exp(2*Z2)*(2*t2*(Z1 + Z2)*pow(Z2,2) + exp(Z1)*t6))*pow(Z1 + Z2,1) ;973 TY_B34 = 6*phi*exp(Z1  2*Z2)*pow(TY_q22,2)*pow(Z2,3)*(2*TY_qc223*TY_qc232*(Z1 + Z2)*exp(Z1)*pow(Z2,2) + 2*exp(Z2)*t1 + exp(2*Z2)*(2*t2*(Z1 + Z2)*pow(Z2,2) + exp(Z1)*t6))*pow(Z1 + Z2,1) 922 974 923 975 … … 1113 1165 TY_w[3] += TY_B24*TY_G14*TY_G23  TY_B23*TY_G15*TY_G23  TY_B22*TY_G16*TY_G23  TY_B21*TY_G17*TY_G23  TY_B24*TY_G13*TY_G24  TY_B23*TY_G14*TY_G24  TY_B22*TY_G15*TY_G24  TY_B21*TY_G16*TY_G24 + 2*TY_B14*TY_G23*TY_G24 1114 1166 TY_w[3] += TY_B23*TY_G13*TY_G25  TY_B22*TY_G14*TY_G25  TY_B21*TY_G15*TY_G25 + 2*TY_B14*TY_G22*TY_G25 + 2*TY_B12*TY_G24*TY_G25  TY_B22*TY_G13*TY_G26  TY_B21*TY_G14*TY_G26 + 2*TY_B12*TY_G23*TY_G26  TY_B21*TY_G13*TY_G27 1115 TY_w[3] += 2*TY_B12*TY_G22*TY_G27 ;1167 TY_w[3] += 2*TY_B12*TY_G22*TY_G27 1116 1168 1117 1169 TY_w[4] = (TY_B25*TY_G15*TY_G22)  TY_B24*TY_G16*TY_G22  TY_B23*TY_G17*TY_G22  TY_B22*TY_G18*TY_G22  TY_B21*TY_G19*TY_G22  TY_B25*TY_G14*TY_G23  TY_B24*TY_G15*TY_G23  TY_B23*TY_G16*TY_G23  TY_B22*TY_G17*TY_G23 
sans/Dev/trunk/NCNR_User_Procedures/Analysis/Models/Teubner_v40.ipf
r570 r931 7 7 // 8 8 // 06 NOV 98 SRK 9 // 10 // JAN 2014  SRK 11 // 12 // Changed the input parameters to be the length scales rather than a2, c1, c2 13 // which have no physical meaning. 9 14 //////////////////////////////////////////////// 10 15 … … 17 22 Make/O/D/n=(num) xwave_ts,ywave_ts 18 23 xwave_ts = alog(log(qmin) + x*((log(qmax)log(qmin))/num)) 19 Make/O/D coef_ts = {0.1,30,5000,0.1} 20 make/o/t parameters_ts = {"scale (a2)","c1","c2","bkg"} 24 // Make/O/D coef_ts = {0.1,30,5000,0.1} 25 // make/o/t parameters_ts = {"scale (a2)","c1","c2","bkg"} 26 27 Make/O/D coef_ts = {0.3,6e6,30,100,0.1} 28 make/o/t parameters_ts = {"scale","SLD difference (A^2)","correlation length (xi) (A)","repeat distance, d, (A)","bkg (1/cm)"} 29 21 30 Edit parameters_ts,coef_ts 22 31 Variable/G root:g_ts … … 47 56 48 57 // Setup parameter table for model function 49 Make/O/D smear_coef_ts = {0. 1,30,5000,0.1}50 make/o/t smear_parameters_ts = {"scale (a2)","c1","c2","bkg"}58 Make/O/D smear_coef_ts = {0.3,6e6,30,100,0.1} 59 make/o/t smear_parameters_ts = {"scale","SLD difference (A^2)","correlation length (xi) (A)","repeat distance, d, (A)","bkg (1/cm)"} 51 60 Edit smear_parameters_ts,smear_coef_ts 52 61 … … 73 82 Wave cw,yw,xw 74 83 84 Variable a2, c1, c2 85 Variable d,xi,scale,delrho 86 87 scale = cw[0] 88 delrho = cw[1] 89 xi = cw[2] 90 d = cw[3] 91 92 93 a2 = (1 + (2*pi*xi/d)^2)^2 94 c1 = 2*xi*xi*(2*pi*xi/d)^2+2*xi*xi 95 c2 = xi^4 96 97 a2 /= 8*pi*xi^3*scale*delrho^2*1e8 //this makes the units work out 98 c1 /= 8*pi*xi^3*scale*delrho^2*1e8 99 c2 /= 8*pi*xi^3*scale*delrho^2*1e8 100 101 // Print a2,c1,c2 102 103 Duplicate/O cw tmp_ts_cw 104 tmp_ts_cw[0] = a2 105 tmp_ts_cw[1] = c1 106 tmp_ts_cw[2] = c2 107 tmp_ts_cw[3] = cw[4] 108 75 109 #if exists("TeubnerStreyModelX") 76 yw = TeubnerStreyModelX( cw,xw)110 yw = TeubnerStreyModelX(tmp_ts_cw,xw) 77 111 #else 78 yw = fTeubnerStreyModel( cw,xw)112 yw = fTeubnerStreyModel(tmp_ts_cw,xw) 79 113 #endif 80 114 return(0) … … 109 143 Endif 110 144 // calculate the correlation length and the repeat distance 111 Variable a2,c1,c2,xi,dd 112 a2 = coef_ts[0] 113 c1 = coef_ts[1] 114 c2 = coef_ts[2] 115 116 xi = 0.5*sqrt(a2/c2) + c1/4/c2 117 xi = 1/sqrt(xi) 118 119 dd = 0.5*sqrt(a2/c2)  c1/4/c2 120 dd = 1/sqrt(dd) 121 dd *=2*Pi 122 145 // Variable a2,c1,c2,xi,dd,fa 146 // a2 = coef_ts[0] 147 // c1 = coef_ts[1] 148 // c2 = coef_ts[2] 149 // 150 // xi = 0.5*sqrt(a2/c2) + c1/4/c2 151 // xi = 1/sqrt(xi) 152 // 153 // dd = 0.5*sqrt(a2/c2)  c1/4/c2 154 // dd = 1/sqrt(dd) 155 // dd *=2*Pi 156 // 157 158 Variable a2, c1, c2 159 Variable d,xi,scale,delrho,fa 160 xi = coef_ts[2] 161 d = coef_ts[3] 162 163 164 a2 = (1 + (2*pi*xi/d)^2)^2 165 c1 = 2*xi*xi*(2*pi*xi/d)^2+2*xi*xi 166 c2 = xi^4 167 168 fa = c1/(sqrt(4*a2*c2)) 169 123 170 Printf "The correlation length (the dispersion of d) xi = %g A\r",xi 124 Printf "The quasiperiodic repeat distance, d = %g A\r",dd 171 Printf "The quasiperiodic repeat distance, d = %g A\r",d 172 Printf "The amphiphilicity factor, fa = %g\r",fa 125 173 126 174 End
Note: See TracChangeset
for help on using the changeset viewer.