I have a program that minimizes the energy of a system by varying displacement x[i]
in x-dimension using a do while
condition loop. I want to extend it to a program that minimizes the energy by varying x[i]
, y[i]
, z[i]
, I suppose, in this case three simultaneous do while
loops are needed inside one big do while
loop, how can I accomplish this?
Code for problem in one dimension is as shown below:
int main(void)
{
double eta,energyold;
energyold=1.0;
unsigned i,j;
init();
do{
function();
functiond(); //JACOBIAN
dgesv(fnd,b,N,dx);
newpsn();
energyT();
eta=fabs(energy-energyold)/energy;
energyold=energy;
//printf("%lf %lf %lf\n",eta,energy,norm);
}while(norm>1e-12);
for(i=0;i<N;i++)
{
printf("The Equillibrium position of ion %d is: %lf\n",i+1,x[i]);
}
return 0;
}