package sansmodels; public class PolyCoreShellRatio extends SANSModel{ private double scale, coreRadius, thickness, background; private double rhoCore, rhoShell, rhoSolvent, polyDisp; //Default constructor public PolyCoreShellRatio() { scale = 1.0; coreRadius = 60.0; thickness = 10.0; polyDisp = 0.2; rhoCore = 1.e-6; rhoShell = 2.e-6; rhoSolvent = 3.e-6; background = 0.000; setNumberOfParameters(8); String[] parameters = {"Scale", "Core Radius (A)", "Shell Thickness (A)", "Polydispersity (0-1)", "Core SLD (A-2)", "Shell SLD (A-2)", "Solvent SLD (A-2)", "Background (cm-1)"}; setParametersText(parameters); } public PolyCoreShellRatio(double inScale, double inCoreRadius, double inThickness, double inPolyDisp, double inRhoCore, double inRhoShell, double inRhoSolvent, double inBackground) { scale = inScale; coreRadius = inCoreRadius; thickness = inThickness; polyDisp = inPolyDisp; rhoCore = inRhoCore; rhoShell = inRhoShell; rhoSolvent = inRhoSolvent; background = inBackground; setNumberOfParameters(8); String[] parameters = {"Scale", "Core Radius (A)", "Shell Thickness (A)", "Polydispersity (0-1)", "Core SLD (A-2)", "Shell SLD (A-2)", "Solvent SLD (A-2)", "Background (cm-1)"}; setParametersText(parameters); } private double fnt2(double inY, double inZ) { double z1, z2, z3, uu, ww, term1, term2, term3; z1 = inZ+1.0; z2 = inZ+2.0; z3 = inZ+3.0; uu = inY/z1; ww=Math.atan(2.0*uu); term1 = Math.cos(z1*ww)/Math.pow((1.0+4.0*uu*uu),(z1/2.0)); term2 = 2.0*inY*Math.sin(z2*ww)/Math.pow((1.0+4.0*uu*uu),(z2/2.0)); term3 = 1.0 + Math.cos(z3*ww)/Math.pow((1.0+4.0*uu*uu),(z3/2.0)); return (4.5/z1/Math.pow(inY,6.0))*(z1*(1.0-term1-term2) +inY*inY*z2*term3); } private double fnt3(double inY, double inP, double inZ) { double z1,z2,z3,yp,yn,up,un,vp,vn,term1; double term2,term3,term4,term5,term6, answer; z1 = inZ+1.0; z2 = inZ+2.0; z3 = inZ+3.0; yp = (1.0+inP)*inY; yn = (1.0-inP)*inY; up = yp/z1; un = yn/z1; vp = Math.atan(up); vn = Math.atan(un); term1 = Math.cos(z1*vn)/Math.pow((1.0+un*un),(z1/2.0)); term2 = Math.cos(z1*vp)/Math.pow((1.0+up*up),(z1/2.0)); term3 = Math.cos(z3*vn)/Math.pow((1.0+un*un),(z3/2.0)); term4 = Math.cos(z3*vp)/Math.pow((1.0+up*up),(z3/2.0)); term5 = yn*Math.sin(z2*vn)/Math.pow((1.0+un*un),(z2/2.0)); term6 = yp*Math.sin(z2*vp)/Math.pow((1.0+up*up),(z2/2.0)); answer = (4.50/z1/Math.pow(inY,6.0)); answer = answer*(z1*(term1-term2)+inY*inY*inP*z2*(term3+term4) +z1*(term5-term6)); return answer; } public double getFormFactor(double inX) { double zz, drho1, drho2, pp, totalRadius; double pi43, c1, c2, form, vol, arg1, arg2; totalRadius = coreRadius + thickness; if (polyDisp <= 0.0) polyDisp = 0.0001; if (polyDisp >= 1.0) polyDisp = 1.0; zz = 1.0/polyDisp/polyDisp - 1.0; drho1 = rhoCore - rhoShell; drho2 = rhoShell - rhoSolvent; pi43 = 4.0/3.0*Math.PI; pp = coreRadius/totalRadius; vol = pi43*totalRadius*totalRadius*totalRadius; c1 = drho1*vol; c2 = drho2*vol; arg1 = inX*totalRadius*pp; arg2 = inX*totalRadius; form = Math.pow(pp,6.0)*c1*c1*fnt2(arg1,zz); form += c2*c2*fnt2(arg2,zz); form += 2.0*c1*c2*fnt3(arg2,pp,zz); return form/vol*1.0e8*scale*getStructureFactor().calculate(inX) +background; } public void setParameters(double[] inParameters) { scale = inParameters[0]; coreRadius = inParameters[1]; thickness = inParameters[2]; polyDisp = inParameters[3]; rhoCore = inParameters[4]; rhoShell = inParameters[5]; rhoSolvent = inParameters[6]; background = inParameters[7]; } public double[] getParameters() { double[] outParameters = new double[8]; outParameters[0] = scale; outParameters[1] = coreRadius; outParameters[2] = thickness; outParameters[3] = polyDisp; outParameters[4] = rhoCore; outParameters[5] = rhoShell; outParameters[6] = rhoSolvent; outParameters[7] = background; return outParameters; } }