The Tank.A(area) is calculated as: Tank[j].A = PI*SQR(Tank[j].A/Ucf[ELEV])/4.0; //diameter is stored in Tank[j].A so the right equation to get the diameter back is sqrt(4.0/PI*Tank[index-Njuncs].A)*Ucf[ELEV];