1. The variable needs to be increased to find the solution
2. The variable needs to be decreased to find the solution
The problem I have is that I cannot think of a way to enter statements so that only one of the above iterative loops is carried out. At the moment as soon as the variable crosses 0 there is an oscillation as the program flicks between the values and I have to terminate the program. I know that there is a way to set true/false statements but I haven't found a way to do this without the value being reset when the loop goes back to the start.
Here's part of the code without the formulae:
Expand|Select|Wrap|Line Numbers
- if (n_e-n_e_new < 0) /*If n_e is too big then decrease n_e CHANGE CONDITION*/
- {
- n_e *= 0.5;
- }
- else
- {
- n_e *= 1.5 ;
- }