package sansmodels; public class PolyCoreShell extends SANSModel{ private double scale, coreRadius, thickness, background; private double rhoCore, rhoShell, rhoSolvent, corePolyDisp; //Default constructor public PolyCoreShell() { scale = 1.0; coreRadius = 60.0; corePolyDisp = 0.2; thickness = 10.0; rhoCore = 1.e-6; rhoShell = 2.e-6; rhoSolvent = 3.e-6; background = 0.000; setNumberOfParameters(8); String[] parameters = {"Scale", "Core Radius (A)", "Core Polydisp. (0-1)", "Shell Thickness (A)", "Core SLD (A-2)", "Shell SLD (A-2)", "Solvent SLD (A-2)", "Background (cm-1)"}; setParametersText(parameters); } public PolyCoreShell(double inScale, double inCoreRadius, double inCorePolyDisp, double inThickness, double inRhoCore, double inRhoShell, double inRhoSolvent, double inBackground) { scale = inScale; coreRadius = inCoreRadius; corePolyDisp = inCorePolyDisp; thickness = inThickness; rhoCore = inRhoCore; rhoShell = inRhoShell; rhoSolvent = inRhoSolvent; background = inBackground; setNumberOfParameters(8); String[] parameters = {"Scale", "Core Radius (A)", "Core Polydisp. (0-1)", "Shell Thickness (A)", "Core SLD (A-2)", "Shell SLD (A-2)", "Solvent SLD (A-2)", "Background (cm-1)"}; setParametersText(parameters); } public double getFormFactor(double inX) { double zz, drho1, drho2; double d, g, form; double x, y, c1, c2, c3, c4, c5, c6, c7, c8, c9, t1, t2, t3; double t4, t5, tb, cy, sy, tb1, tb2, tb3, c2y, zp1, zp2; double zp3,vpoly; double s2y, arg1, arg2, arg3; if(corePolyDisp <= 0.0) corePolyDisp = 0.0001; if(corePolyDisp >= 1.0) corePolyDisp = 1.0; zz = 1.0/corePolyDisp/corePolyDisp - 1.0; drho1 = rhoCore - rhoShell; if(Math.abs(drho1) <= 1.e-10) drho1 = 1.e-10; drho2 = rhoShell - rhoSolvent; g = (-1.0)*drho2/drho1; zp1 = zz + 1; zp2 = zz + 2; zp3 = zz + 3; vpoly = 4.0*Math.PI/3.0*zp3*zp2/zp1/zp1 *Math.pow((coreRadius+thickness),3.0); y = inX * thickness; x = inX * coreRadius; d = Math.atan(x*2.0/zp1); arg1 = zp1 * d; arg2 = zp2 * d; arg3 = zp3 * d; sy = Math.sin(y); cy = Math.cos(y); s2y = Math.sin(2.*y); c2y = Math.cos(2.*y); c1 = .5 - g * (cy + y * sy) + g * g * .5 * (y * y + 1.); c2 = g * y * (g - cy); c3 = (g * g + 1.) * .5 - g * cy; c4 = g * g * (y * cy - sy) * (y * cy - sy) - c1; c5 = g * 2. * sy * (1. - g * (y * sy + cy)) + c2; c6 = c3 - g * g * sy * sy; c7 = g * sy - g * .5 * g * (y * y + 1.) * s2y - c5; c8 = c4 - .5 + g * cy - g * .5 * g * (y * y + 1.) * c2y; c9 = g * sy * (1. - g * cy); tb = Math.log(zp1 * zp1 / (zp1 * zp1 + x * 4. * x)); tb1 = Math.exp(zp1 * .5 * tb); tb2 = Math.exp(zp2 * .5 * tb); tb3 = Math.exp(zp3 * .5 * tb); t1 = c1 + c2 * x + c3 * x * x * zp2 / zp1; t2 = tb1 * (c4 * Math.cos(arg1) + c7 * Math.sin(arg1)); t3 = x * tb2 * (c5 * Math.cos(arg2) + c8 * Math.sin(arg2)); t4 = zp2 / zp1 * x * x * tb3 * (c6 * Math.cos(arg3) + c9 * Math.sin(arg3)); t5 = t1 + t2 + t3 + t4; form = t5 * 16. * Math.PI * Math.PI * drho1 * drho1 / Math.pow(inX,6.0); return form/vpoly*1.0e8*scale*getStructureFactor().calculate(inX) + background; } public void setParameters(double[] inParameters) { scale = inParameters[0]; coreRadius = inParameters[1]; corePolyDisp = inParameters[2]; thickness = 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] = corePolyDisp; outParameters[3] = thickness; outParameters[4] = rhoCore; outParameters[5] = rhoShell; outParameters[6] = rhoSolvent; outParameters[7] = background; return outParameters; } }