package sansmodels; public class CoreShell extends SANSModel{ private double scale, coreRadius, thickness, background; private double rhoCore, rhoShell, rhoSolvent; //Default constructor public CoreShell() { scale = 1.0; coreRadius = 60.0; thickness = 10.0; rhoCore = 1.e-6; rhoShell = 2.e-6; rhoSolvent = 3.e-6; background = 0.00; setNumberOfParameters(7); String[] parameters = {"Scale", "Core Radius (A)", "Shell Thickness (A)", "Core SLD (A-2)", "Shell SLD (A-2)", "Solvent SLD (A-2)", "Background (cm-1)"}; setParametersText(parameters); } public CoreShell(double inScale, double inCoreRadius, double inThickness, double inRhoCore, double inRhoShell, double inRhoSolvent, double inBackground) { scale = inScale; coreRadius = inCoreRadius; thickness = inThickness; rhoCore = inRhoCore; rhoShell = inRhoShell; rhoSolvent = inRhoSolvent; background = inBackground; setNumberOfParameters(7); String[] parameters = {"Scale", "Core Radius (A)", "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 bes, f, vol, f2,qr,contr; //Core first qr = inX*coreRadius; contr = rhoCore - rhoShell; bes = 3.*(Math.sin(qr) - qr*Math.cos(qr))/ Math.pow(qr,3.0); vol = 4.0*Math.PI/3.0*Math.pow(coreRadius,3.0); f = vol*bes*contr; //Then Shell qr = inX*(coreRadius+thickness); contr = rhoShell - rhoSolvent; bes = 3.*(Math.sin(qr) - qr*Math.cos(qr))/ Math.pow(qr,3.0); vol = 4.0*Math.PI/3.0*Math.pow(coreRadius+thickness,3.0); f += vol*bes*contr; f2 = f*f/vol*1.0e8; return scale*f2*getStructureFactor().calculate(inX) + background; } public void setParameters(double[] inParameters) { scale = inParameters[0]; coreRadius = inParameters[1]; thickness = inParameters[2]; rhoCore = inParameters[3]; rhoShell = inParameters[4]; rhoSolvent = inParameters[5]; background = inParameters[6]; } public double[] getParameters() { double[] outParameters = new double[7]; outParameters[0] = scale; outParameters[1] = coreRadius; outParameters[2] = thickness; outParameters[3] = rhoCore; outParameters[4] = rhoShell; outParameters[5] = rhoSolvent; outParameters[6] = background; return outParameters; } }