package sansmodels; public class TwoHomopolymerRPA extends SANSModel{ private double na, nb, phi, va, vb, deltaRho, aa, ab; private double interaction, background; //Default constructor public TwoHomopolymerRPA() { na = 1000.0; nb = 1000.0; phi = 0.2; va = 100.0; vb = 100.0; deltaRho = 2.0e-6; aa = 6.0; ab = 7.0; interaction = 0.0; background = 0.0; setNumberOfParameters(10); String[] parameters = {"Polymerization A","Polymerization B", "Vol. Frac A", "Seg. Vol. A(cm^3/mol)", "Seg. Vol. B(cm^3/mol)", "deltaRho A-B (A-2)", "Seg. Length A (A)", "Seg. Length B (A)", "Interaction AB","Background (cm-1)"}; setParametersText(parameters); } public TwoHomopolymerRPA(double inNa, double inNb, double inPhi, double inVa, double inVb, double inDeltaRho, double inAa, double inAb, double inInt, double inBackground) { na = inNa; nb = inNb; phi = inPhi; if(phi >= 1.0) phi = 0.999999; va = inVa; vb = inVb; deltaRho = inDeltaRho; aa = inAa; ab = inAb; interaction = inInt; background = inBackground; setNumberOfParameters(10); String[] parameters = {"Polymerization A","Polymerization B", "Vol. Frac A wrt B", "Seg. Vol. A(cm^3/mol)", "Seg. Vol. B(cm^3/mol)", "deltaRho A-B (A-2)", "Seg. Length A (A)", "Seg. Length B (A)", "Interaction AB","Background (cm-1)"}; setParametersText(parameters); } public double getFormFactor(double inX) { double term1, term2, term3, term4, sq, rg, debye, x; rg = Math.sqrt(na*aa*aa/6.0); x = inX*inX*rg*rg; debye = 2.0*(Math.exp(-1.0*x) + x - 1.0)/(x*x); term1 = 1.0/(na*va*phi*debye); rg = Math.sqrt(nb*ab*ab/6.0); x = inX*inX*rg*rg; debye = 2.0*(Math.exp(-1.0*x) + x - 1.0)/(x*x); term2 = 1.0/(nb*vb*(1.0-phi)*debye); term3 = 2.0*interaction/Math.sqrt(va*vb); term4=deltaRho*deltaRho*1.6606e8; sq = term4/(term1 + term2 - term3); return sq*getStructureFactor().calculate(inX) + background; } public void setParameters(double[] inParameters) { na = inParameters[0]; nb = inParameters[1]; phi = inParameters[2]; if(phi >= 1.0) phi = 0.999999; va = inParameters[3]; vb = inParameters[4]; deltaRho = inParameters[5]; aa = inParameters[6]; ab = inParameters[7]; interaction = inParameters[8]; background = inParameters[9]; } public double[] getParameters() { double[] outParameters = new double[10]; outParameters[0] = na; outParameters[1] = nb; outParameters[2] = phi; outParameters[3] = va; outParameters[4] = vb; outParameters[5] = deltaRho; outParameters[6] = aa; outParameters[7] = ab; outParameters[8] = interaction; outParameters[9] = background; return outParameters; } }