Problem in a DLA simulation

The main problem is this: how can I return to put a "particle" in r0 (if the antecedent particle go out the circle) unless I used a break and a goto statement to the comment I post in the code as //insertion of a new particle.

Please note that the code is not well done yet. But I'm stuk in that.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <iostream>
#include <cmath>
#include <string>
#include "libnum/libnum.h"
#include <fstream>

using namespace std;

int main ()
{
int N=1000;
int c_r= N, c_teta= N, iteracao=10;

double raio_inicial= 10, rmin= 0.1, teta_inicial, x, y, x0, y0, r, ri;
double r0=10, r, teta, dr, dteta, pi= 3.141592654;
double coordenadas [N];

ofstream myfile ("DLA.dat");
LIBNUM::RngInit ();

 while (ri>rmin && ri <= r0)
 {
   for (int i= 0; i < iteracao; i++)
   {
     i = LIBNUM::RngDouble ();
     teta= i*(2*pi);
     x0 = r0 * cos (teta);                     //insertion of a new particle
     y0 = r0 * sin (teta);



	for (int i = 0; i < iteracao; i++)
	{
	   i = LIBNUM::RngDouble ();
	   i = i - 0.5;
	   x = x0 + i/5.0;
	   i = LIBNUM::RngDouble();
	   i = i-0.5;
	   y = y0 + i/5.0;
	 }
	     for (int i = 0; i < iteracao; i++)
	     {
                  ri= hypot (x,y);
		  coordenadas [i] = ri;

      }
		     if (r > r0)
		     {
		       i = LIBNUM::RngDouble ();
   	               teta= i*(2*pi);
                       x0 = r0 * cos (teta);
                       y0 = r0 * sin (teta);
		      }
}
}


cout<<i<<" "<< "dr"<< " "<< dr<< "dteta"<< " "<<dteta<< endl;

myfile << dr << " "<< dteta << endl;



myfile.close ();

return 0;
}
Topic archived. No new replies allowed.