Can anyone help me whats wrong with this


Joined
Jun 2, 2022
Messages
1
Reaction score
0
Can anyone help me with this bit of code ill show you the whole script and then show you the bit that dosen't work.

Code:

public class se
{

double Psi[];
double ECurrent;
double Emin = 1.490;
double xMin = -15;
double xMax = 15.;
double hZero;
double EDelta = 0.0000001;
double maxPsi = 0.00000001;
int numberDivisions = 200;
public se()
{
ECurrent = Emin;
psi = new double[numberDivisions + 1];
psi[0] = 0;
psi[1] = -0.00000001;
psi[numberDivisions] = 1.0;
hZero = (xMax - xMin) / numberDivisions;
}

public static void main(String [] argv)
{
se de = new se();
de.calculate();
}

public void calculate()
{
while(Math.abs(psi[numberDivisions])> maxPsi){
for (int i = 1; i <numberDivisions; i++){
psi[i + 1] = calculateNextPsi (i);
}
if (psi[numberDivisions]> 0.0) {
Ecurrent = ECurrent - EDelta;
}
else {
ECurrent = ECurrent + EDelta;
}

System.out.println(ìPsi200: ì + psi[numberDivisions]
+ ì E: ì + round(ECurrent));


}
System.out.println(ì\nThe ground state energy ì +
round(ECurrent) + ì MeV.î);


}

public double calculateKSquared(int n)
{
double x = (hZero * n) + xMin;
return (((0.5) * ECurrent) - ((x * x) * 5.63e-3));
}

public double calculateNextPsi(int n)
{
double KSqNMinusOne = calculateKSquared(n - 1);
double KSqN = calculateKSquared(n);
double KSqNPlusOne = calculateKSquared(n + 1);
double nextPsi = 2.0 *(1.0 - (5.0 * hZero * hZero *
KSqN / 12.0)) * psi[n];
nextPsi = nextPsi - (1.0 + (hZero * hZero *
KSqNMinusOne / 12.0)) * psi[n - 1];
nextPsi = nextPsi /(1.0 + (hZero * hZero * KSqNPlusOne
/ 12.0));
return nextPsi;

}

public double round(double val)
{
double divider = 100000;
val = val * divider;
double temp = Math.round(val);
return (double)temp / divider;
}
}

The Part That Needs Fixing:

System.out.println(ìPsi200: ì + psi[numberDivisions]
+ ì E: ì + round(ECurrent));


}
System.out.println(ì\nThe ground state energy ì +
round(ECurrent) + ì MeV.î);

Please if you know a fix post it in the comments.
Thanks in advance!
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top