Вы находитесь на странице: 1из 42

-

,
.-. ,

..

,
.-. ,

..

,
.-. ,

..

-
2011

2
2.1 . . . . . . .
2.2
2.3 n = 3 . . .
2.4 . . . . . .

3
3
3
4
7

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

3
8
3.1 . . .
8
3.2 9
4
12
4.1 . . . . . . . . . . . . . . . . . . . . 13
4.2 . . . . . . . 13
4.3 . . . . . . . . . . . . . . . . . . . 14
5
17
5.1 . . . . . . 17
5.2 . . . . . . . . . . . . . . . . . . . . . . . 18

20

23

25


[4]
- , . . , : -, , ; -, , . , ,
. , . [3]. [4] ,
,
.


n = 3 [4]. ,
[3]. ,
,
. :
1. .
2. .
,

. , .
3. . .
4.
, .
5.
.
6. ( , ..).

2
2.1

.
,
, :
ur = z 0 , u =

p
G

, uv = u , 0 6 < 1, 1 2 ,
z0

(1)

G , z0 , . = 0
, 1, .

2.2

, [4] , 3


,
z = z0 . , . ,
1 , 2 . 1 , 2
R z :
q
R = (12 1) (1 22 ), z = 1 2 , 1 6 1 < , 0 6 2 < 1. (2)
, [4], :
1 2
,
(3)
= 2
1 22
1,2 1,2 . 2 < 1 1 6 1 , 1
2 (), ,
(0) = 0. , (3)

z = 0.
[4] 1 ,
2 :
i2 = 2 i2 + 2 , i = 1, 2,
(4)

 n

k
,
() =
n

(5)

k, n , k > 0.
1 , 2 u = z0 /.

2.3

n = 3

[4], n = 3 1 , 2 :
1
= , (1 , 2 ) =
,
(6)
1 + 2
4

1 1 < , 2 < 1 (. . 1).

. 1. 1 , 2 = 0.5.
.

[4] ,
R z:

R = (12 1) (1 22 ),
q
(7)

z = ( 2 2 ) ( 2 2 ).
2
1

. 2 ,
1 2 .

. ,
. .
(7):


R2 = 12 1 1 22 = 12 + 22 12 22 1.
1 2 , ,
R2 = 12 + 22 2 1.
5

(8)

. 2. 1 , 2 . . z = z0
.
2 (8),
R2 = (1 2 )2 ( 1)2 .

(9)

, :

q
q

21 = R2 + ( + 1)2 + R2 + ( 1)2 ,
q
q
(10)

2
2
22 = R2 + ( + 1) R2 + ( 1) .

,
. (10)
s
z 2 + 2 R2
.
(11)
1 2 = 2 +
2
, (10) (11) .
(10)
(6) .
1
,
(R, z) = q
2
2
R + [(R, z) + 1]
6

(12)

(11). (6)
(12) .

. 3. = 0.125.
.
.

2.4

, , . (1) :
uE = u , uI = ur uv , uK = u2r u .
, [4], :


1 2

2
2

v
+
v
+
v
E
=

(
,

1
2
1
2
,

q
(13)
I = (12 1) (1 22 )v ,

K = 2 2  v 2 + 2 2  v 2 + 2 2  2 2  v 2 2* ,
2

E , , I , K .
7

v1 , v2 , v 1 , 2 . * (1 , 2 )
,
, [4].
[4]
:


1

E = (R, z) vR2 + v2 + vz2 ,

2
(14)
I = Rv ,

K = (Rv zv )2 + z 2 v 2 + v 2 2* .
z

3.1

(., , [7]),
-

r = (r), r = (R, , z)T .

(15)

, .
(15)
. , [11], :

I2

+
,
R
=
v
,
v

R
R

R3 R

I
(16)
= 2 ,

z = vz , v z = .
z

3.2

, , ,
. .
1 , 2 . , , [9]:
L=


1 2
vR + v2 + vz2 + .
2

(17)

,
,
(7)

s
s

1 2
12 1

vR = 1 2 1 1 2 1 2 2 ,
1
2
s
s
(18)

2
2
2
2

2 2
1

vz = 1 2 2 1 + 2 2 2 2 .
1

,
(., , [8]):
2
vm
= vR2 + vz2 .

(19)

(18) (19), ,

#
"
2
2
2
2


1 1
2 2
2
vm
= 2 12 22
.
(20)
+
(12 1) (12 2 ) (1 22 ) (22 2 )

v (., , [11]):

v = R .
(7) (21),
q

v = (12 1) (1 22 ) .
9

(21)

(22)

(6), (20) (22) (17),


:
#
"
2 2
2 2

1
2 2
1 1
L = 2 12 22
+
+
2
2
2
2
(1 1) (1 2 ) (1 2 ) (22 2 )
(23)


1
1 2
.
1 1 1 22 2 +
+
2
1 + 2

, , [9],
= 0.

, [9]:
L,
H(q, p) = 1 p1 + 2 p2 + p

(24)

p1 , p2 , p . . [9],
:
L
L
L
, p2 =
, p =
p1 =
.
1
2

(23),


2
2
2

p1 = 2 2 1 1 2 2 2 1 ,

(1 1) (1 )


2
2
2

(25)
2
1
2
2 ,
p2 = 2

2
2

(1 2 ) (2 )

p = 2 1 1 2  .

1
2
, :

-, (25) ;
-, (25):

10

 2


2
2

p1 ,
1 = 2 1 2 2 1 2

1 1
2

2
2
2
1

1
2
2
(26)
p2 ,
2 = 2
2)
2
2

2
1
2

= 2
p .
(1 1) (1 22 )
,
(25) (24):

1 2
(27)
1 p1 + 2 p22 + 3 p2 (1 , 2 ),
H=
2
1 , 2 , 3 , :


1 12 1 12 2
1 = 2
,

12 (12 22 )


1 1 22 22 2
,
2 = 2

22 (12 22 )
1
3 = 2
.
(1 1) (1 22 )
, (1):
uH = uE = u .
,
[9]:
H
H
H
, p2 =
, p =
.
1
2

(28)

2
=
=
2 = .
1
2
(1 + 2 )

(29)

p1 =
,

, (28), (29) :


1
2
2
2
2

p
+

p
+

p
1
1,1 1
2,1 2
3,1 + ,


1
2
2
2
2
(30)

p
+

p
+

p
p

1,2 1
2,2 2
3,2 + ,
2

p = 0,

11

i,1 = i /1 , i,2 = i /2 , i = 1, 2, 3, ,
:


2


2 12 1 + 14 2 1 22

,
1,1 = 2

2 3 ( 2 2 )2

2

1 21

2
2
21 1 2 2
(31)
,

=
2,1
2

2
2
2
2

2 (1 2 )

21

,
3,1 = 2
2
(1 1) (1 22 )
 2


2
2
+2

1
1

,
1,2 =

2
2
2
2

1 (1 2 )


2


2 1 22 + 12 1 2 24
(32)
,
2,2 = 2
2

3
2
2
2

2 (1 2 )

22

3,2 = 2
2.
(1 1) (1 22 )

, p = 0, 1 , 2 , 3
.
(26), (30) , (31)
(32),
.

(16) ( ) (26), (30) (31)(32)


( ) , , ,
.
. [10],
.

12

4.1

, [10], I E, (14).
R, z
E =

I2
,
2R2

(33)

, vm (19). R z
. , , I E
R z.
. , , .
I2
E+
= 2 , 6= 0,
2
2R

(34)

. , (14) (19),
2
vm
= vR2 + vz2 = 2 . R z .
z = 0, , .
. ,
K
, . ,
(I, E).

4.2

[1]. E, I K.
13

[4]:



wi2 = i2 i2 1 E i2 I i2 1 K + 2 i2 1 i ,

(35)

wi2 (E, I, K, i ) = 0
i , i = 1, 2.

. 4. = 0.1, R = 2.452,
z = 0.744, 4.3
.

4.3

.
, ,
.
,

, . Vc (R). [6], z = 0
:
Vq2 (R, z) R

(R, z)
,
R
14

Vq2 (R, 0) = Vc2 (R) .

(36)

:
= 0.1, = 0.5, = 0.9.

. 5. .
0.1 , ,
0.9 , . . 5
. R1 , R2 , R3 , . . . , Vq (R, zk )
(. . 6). zk :
z1 = 0, z2 =

R2
R1
, z3 =
, ....
2
2

(Rk , zk ) k = (Rk , zk ) (12).


(. 7) Il
:
Il = Ic (R1 ) + (l 2)I, l = 1, 2, 3, 4,
(37)
Ic (R1 )
, I
I:
I =

1
[Imax Ic (R1 )] .
2
15

. 6. = 0.1. 13
k Rk .

. 7. = 0.1. k (33).

16

Ekl k- l-
I = Il . Il Ekl (v )l (vm )kl , .
. :
2
2
vR2 = nvm
, vz2 = vm
vR2 , n = 0, 0.25, 0.5, 0.75, 1,
, vR .
, vz .

5
5.1

(. . 14),
(16) .

y(t0 ) = x0 ,
y , (16), x ,
.
-
c . C# (-), [13]. Maple ( 13) gnuplot [2].
, .
. Maple ,

.
.
17

t, , .
(1):
uR
ut = .
u
T
Vc (R ), (36),
Vc (R ). T Vc (R ) (.,
, [8]):
2R
T =
, Vc (R ) = max Vc (R).

R
Vc (R )
, E. ,
, , ( ),
. E = E/E0 . E = E E0 , E0
, E , (13).

, .
z = 0. E 0.17 106 100 (. 8).

5.2

400
150 . ( ,
100 ). (. . 23).
:
18

. 8. .

1. , .


(
, 1). , , . , . . 23
. 9.
2. , (0)
vR . vR
(max)
(max)
, 0.5Vc
0.1Vc
(max)
(0)
. 0.5Vc
< vR <
Vesc , .
. 24 . 10.
3. , vR . , . . 24
. 11.
19

4. , [12]. , -
. ,
(0)

0.5Vcmax < |vR | < Vesc , 0.5Vcmax < |vz(0) | < Vesc .
.25 . 13.
5. , . (0)
z (0) = 0 vz = 0.
(. . 24 . 12).
6. , . (. . 25 . 14).

(27),
(26), (30)(32). ,

.
K , , [4].
1 ,
.

20


1. T. de Zeeuw. Elliptical galaxies with separable potentials // MNRAS:
1985. 216, P. 273334.
2. Ocial gnuplot documentation.
http://gnuplot.sourceforge.net/docs_4.4/gnuplot.pdf
3. .. /
. . . .. .. . .: .
2002. 288 .
4. .. , // . ., 1956. . 33. . 1.
. 2744.
5. .., .. // ,
1963. 6. . 1015.
6. .. / . ., 1991. 296 .
7. .., .. //
. .:
. . 1981. . 4662.
8. .., ..
// . . 10, 2008. . 1. . 3242.
9. .., .. . / .1: .
4- . .: , 1988. 216 .
10. . . // . . .: , 1962. . 39132.
11. .. . / .: ,
1958. 641 .
21

12. .., .., .. // . . 1, 2001.


. 3. . 8188.
13. . # / . . .: .
, 2004. 752 .

22

.
. 1 .

(0)

1. .
z (0)
vR0
v0
vz0
.

0.100 2.451 0.744 0.000

0.400 0.000 1

9,

0.900 2.810 0.735 0.000

0.400 0.000 1

9,

0.100 2.451 0.744 0.150

0.300 0.400 2

10

0.500 1.567 0.000 0.300 0.400 0.600 3

11

0.100 3.133 1.226 0.600 0.200 0.763 4

13

0.100 1.480 0.000 0.100

0.400 0.000 5

12

0.500 1.480 0.000 0.700

0.400 0.000 5

12

0.100 3.133 1.226 0.7

0.4

14

0.7

. 9. , ( 1).

23

. 11.
. 10. ( 2).
( 3).

. 12. ,
( 5).

24

. 13. ,
. 14.

( 6).
( 4).

.
, .
.
using System;
using System.IO;
namespace StellarApplication1
{
//
public abstract class Equations
{
// -
public static double gamma, R, z, theta,
VR, Vtheta, Vz;
// . .
public static double Chi(double gamma,
25

double R, double z)
{
double chi;
if (gamma == 0.0)
chi = z;
else
chi = Math.Sqrt(gamma * gamma
+ (z * z + gamma * gamma * R * R)
/ (1 - gamma * gamma));
return chi;
}
// . .
public static double Potential(
double gamma,
double R, double z)
{
double Potential, chi;
chi = Chi(gamma, R, z);
Potential = 1 / Math.Sqrt(R * R
+ Math.Pow((Math.Abs(chi)
+ 1), 2.0));
return Potential;
}
// R
public static double DerivationOfPotentByR(
double gamma, double R, double z)
{
double DerPotentR, potential, chi;
26

chi = Chi(gamma, R, z);


potential = Potential(gamma, R, z);
if (gamma == 0.0)
DerPotentR = -R * Math.Pow(potential, 3);
else
DerPotentR = -R * (Math.Abs(chi)
+ gamma * gamma)
* Math.Pow(potential, 3.0)
/ Math.Abs(chi) / (1 - gamma * gamma);
return DerPotentR;
}
// o z
public static double DerivationOfPotentByZ(
double gamma, double R, double z)
{
double DerPotentZ, potential, chi;
chi = Chi(gamma, R, z);
potential = Potential(gamma, R, z);
if (gamma == 0.0)
DerPotentZ = - (Math.Abs(z) + 1)
* Math.Pow(potential, 3);
else
DerPotentZ = -z * (Math.Abs(chi) + 1)
* Math.Pow(potential, 3.0)
/ Math.Abs(chi) / (1 - gamma * gamma);
return DerPotentZ;
}
27

//
public static double RoundVelocity(
double gamma, double R)
{
double derpotentR, RVel;
derpotentR = DerivationOfPotentByR(gamma, R, 0);
RVel = Math.Sqrt(-R * derpotentR);
return RVel;
}
/*public static double EscVelocity(double gamma)
{
double potential, escVel;
potential = Potential(gamma, 0, 0);
escVel = Math.Sqrt(2 * potential);
return escVel;
}*/
// . .
public static double IEnergy(double gamma, double R,
double z, double VR, double Vtheta, double Vz)
{
double chi, potential, Energy;
chi = Chi(gamma, R, z);
potential = Potential(gamma, R, z);
Energy = 0.5 * (VR * VR + Vtheta
* Vtheta + Vz * Vz) - potential;

28

return Energy;
}
// . .
public static double IZAngularMomentum(double R,
double Vtheta)
{
double ZAngularMomentum;
ZAngularMomentum = R * Vtheta;
return ZAngularMomentum;
}
// . .
public static double IKuzminIntegral(double gamma,
double R, double z, double VR, double Vtheta,
double Vz)
{
double KuzminIntegral, chi, potential, Phi;
chi = Chi(gamma, R, z);
potential = Potential(gamma, R, z);
Phi = (R * R + z * z + chi * chi + 1) * potential;
KuzminIntegral = Math.Pow(R
* Vz - z * VR, 2.0)
+ z * z * Vtheta * Vtheta
+ (Vz * Vz - 2 * Phi);
return KuzminIntegral;
}
// zeta1 . .
public static double ylindricXi(double gamma,
double R, double z)
29

{
double xi, chi;
chi = Chi(gamma, R, z);
xi = Math.Sqrt(R * R + (Math.Abs(chi) + 1)
* (Math.Abs(chi) + 1)) + Math.Sqrt(R * R
+ (Math.Abs(chi) - 1) * (Math.Abs(chi) - 1));
xi /= 2;
return xi;
}
// zeta2 . .
public static double ylindricZeta(double gamma,
double R, double z)
{
double zeta, chi;
chi = Chi(gamma, R, z);
zeta = Math.Sqrt(R * R + (Math.Abs(chi) + 1)
* (Math.Abs(chi) + 1)) - Math.Sqrt(R * R
+ (Math.Abs(chi) - 1) * (Math.Abs(chi) - 1));
zeta /= 2;
if (z < 0)
zeta = -zeta;
return zeta;
}
public static double EllipticalR(double xi,
double zeta)
{
double R;
R = Math.Sqrt((xi * xi - 1) * (1
- zeta * zeta));
30

return R;
} // R . .
public static double EllipticalZ(double gamma,
double xi, double zeta)
{
double z;
z = Math.Sqrt((xi * xi - gamma * gamma)
* (zeta * zeta - gamma * gamma));
return z;
} // z . .
public static double EllPotential(
double xi, double zeta)
{
double Potent;
Potent = 1 / (xi + zeta);
return Potent;
} // . .
public static double EllIEnergy(double gamma,
double xi, double zeta, double V_xi,
double V_zeta, double V_Theta)
{
double IEnergy;
IEnergy = (V_xi * V_xi + V_zeta * V_zeta
+ V_Theta * V_Theta) / 2 - EllPotential(xi, zeta);
return IEnergy;
}
public static double EllIZAngularMomentum(double xi,
double zeta, double impTheta)
{
double IZAngularMomentum;
IZAngularMomentum = EllipticalR(xi,
zeta) * impTheta;
31

return IZAngularMomentum;
}
public static double EllIKuzminIntegral(double gamma,
double xi, double zeta, double V_xi,
double V_zeta, double V_Theta)
{
double phi, KuzminIntegral;
phi = (xi * xi + zeta * zeta)
* (1 - gamma * gamma)
+ Math.Pow(xi * zeta, 2) + Math.Pow(gamma, 4);
KuzminIntegral = (xi * xi - gamma * gamma)
* V_zeta * V_zeta
+ (zeta * zeta - gamma * gamma) * V_xi * V_xi
+ Math.Pow(V_Theta * EllipticalZ(gamma, xi, zeta), 2.0)
- 2 * phi;
return KuzminIntegral;
}
}
// - 4
abstract class TRungeKutta
{
public int N;
double t; //
// Y[0] - ,
// Y[i] - i-
public double[] Y;
//
public double[] Z, ZZ, Z1, Z2, Z3, Z4, Err;
double[] YY, Y1, Y2, Y3, Y4; //
public TRungeKutta(int N) // N -
32

{
this.N = N; //
if (N < 1)
{
this.N = -1;
return;
}
Y = new double[N]; //
YY = new double[N]; //
Y1 = new double[N];
Y2 = new double[N];
Y3 = new double[N];
Y4 = new double[N];
Z = new double[N]; //
ZZ = new double[N]; //
Z1 = new double[N];
Z2 = new double[N];
Z3 = new double[N];
Z4 = new double[N];
Err = new double[N]; //
}
// .
// t0 - , Y0 -
public void SetInit(double t0, double[] Y0)
{
t = t0;
int i;
for (i = 0; i < N; i++)
{
33

Y[i] = Y0[i];
}
}
public double Norm(double[] Y) //
{
double y = 0, norm;
for (int i = 0; i < N; i++)
{
y += Y[i] * Y[i];
}
norm = Math.Sqrt(y);
return norm;
}
//
public double AMax (double[] Y)
{
double a = Y[0];
for (int i = 1; i < N; i++)
{
if (a < Y[i])
a = Y[i];
}
return a;
}
// ,
// http://www.apmath.spbu.ru/ru/structure/depts/is/task7.pdf
public double InitStep (double t0, double[] init)
{
double delta, h;
F(t0, init, ref Z);
delta = Math.Pow(1 / (AMax(init)), 5)
34

+ Math.Pow(Norm(Z), 5);
h = Math.Pow(1e-7 / delta, 0.2);
return h;
}
public double GetCurrent() //
{
return t;
}
// .
abstract public void F(double t,
double[] Y, ref double[] FY);
// -, dt -
public void NextStep(double dt)
{
if(dt < 0)
{
return;
}
int i;
F(t, Y, ref Y1); // Y1
F(t, Y, ref Z1);
for (i = 0; i < N; i++)
{
YY[i] = Y[i] + Y1[i] * (dt / 2.0);
ZZ[i] = Y[i] + Z1[i] * (dt / 4.0);
}
F(t + dt / 2.0, YY, ref Y2); // Y2
F(t + dt / 4.0, ZZ, ref Z2);
35

for (i = 0; i < N; i++)


{
YY[i] = Y[i] + Y2[i] * (dt / 2.0);
ZZ[i] = Y[i] + Z2[i] * (dt / 4.0);
}
F(t + dt / 2.0, YY, ref Y3); // Y3
F(t + dt / 4.0, ZZ, ref Z3);
for (i = 0; i < N; i++)
{
YY[i] = Y[i] + Y3[i] * dt;
ZZ[i] = Y[i] + Z3[i] * (dt / 2.0);
}
F(t + dt, YY, ref Y4); // Y4
F(t + dt, ZZ, ref Z4);
for (i = 0; i < N; i++)
{
//
Y[i] = Y[i] + dt / 6.0 * (Y1[i]
+ 2.0 * Y2[i] + 2.0 * Y3[i] + Y4[i]);
//
Z[i] = Y[i] + dt / 12.0 * (Z1[i]
+ 2.0 * Z2[i] + 2.0 * Z3[i] + Z4[i]);
}
//
F(t, Z, ref Z1);
for (i = 0; i < N; i++)
{
ZZ[i] = Z[i] + Z1[i] * (dt / 4.0);
36

}
F(t + dt / 4.0, ZZ, ref Z2);
for (i = 0; i < N; i++)
{
ZZ[i] = Z[i] + Z2[i] * (dt / 4.0);
}
F(t + dt / 4.0, ZZ, ref Z3);
for (i = 0; i < N; i++)
{
ZZ[i] = Z[i] + Z3[i] * (dt / 2.0);
}
F(t + dt, ZZ, ref Z4);
for (i = 0; i < N; i++)
{
//
Z[i] = Z[i] + dt
/ 12.0 * (Z1[i]
+ 2.0 * Z2[i] + 2.0 * Z3[i] + Z4[i]);
Err[i] = Math.Abs(Y[i]
- Z[i]) / (1 - Math.Pow(2.0, -4.0));
}
if (Norm(Err) > 1e-7)
dt /= 2.0;
else
dt *= 2.0;
t = t + dt; //
}
}
37

//
class TMyRK : TRungeKutta
{
public TMyRK(int aN) : base(aN) { }
public override void F(double t,
double[] Y, ref double[] FY)
{
FY[0] = Y[3];
FY[1] = Equations.IZAngularMomentum(
Equations.R,
Y[4]) / Y[0] / Y[0];
FY[2] = Y[5]; // dot z = vz
FY[3] = Equations.DerivationOfPotentByR(
Equations.gamma,
Y[0], Y[2])
+ Math.Pow(Equations.IZAngularMomentum(
Equations.R,
Y[4]), 2.0)
/ Math.Pow(Y[0], 3.0);
FY[5] = Equations.DerivationOfPotentByZ(
Equations.gamma,
Y[0], Y[2]);
return;
}
}
//
class Program
{
static void Main(string[] args)
{
//
38

StreamWriter
StreamWriter
StreamWriter
StreamWriter

data = new StreamWriter("data1.dat");


energy = new StreamWriter("energy.dat");
error = new StreamWriter("error.dat");
Cartesian = new StreamWriter("cartes.dat");

// ,
data.Flush();
energy.Flush();
error.Flush();
Cartesian.Flush();
TMyRK RK4 = new TMyRK(6); //
//
Equations.gamma = 0.1;
Equations.R = 1.48;
Equations.theta = 0;
Equations.z = 0;
Equations.VR = 0.5;
Equations.Vtheta = 0.2;
Equations.Vz = 0;
double[] Y0 = { Equations.R,
Equations.theta, Equations.z,
Equations.VR, Equations.Vtheta, Equations.Vz };
double DoublePeriod = 0;
double Period = 0;
double xCoord = Y0[0] * Math.Cos(Y0[1]);
double yCoord = Y0[0] * Math.Sin(Y0[1]);
//
double Energy0 = (Y0[3] * Y0[3]
+ Y0[4] * Y0[4] + Y0[5] * Y0[5]) / 2.0;
39

double Energy, locError, time, ptime;


//
RK4.SetInit(0, Y0);
//
double delta, h;
RK4.F(0, RK4.Y, ref RK4.Z);
delta = Math.Pow(1 / (RK4.AMax(RK4.Y)), 5)
+ Math.Pow(RK4.Norm(RK4.Z), 5);
h = Math.Pow(1e-7 / delta, 0.2);
//
Console.WriteLine("Counting...");
Console.WriteLine("gamma = "
+ Equations.gamma + "; R = "
+ Equations.R + "; theta = " + Equations.theta + ";
z = " + Equations.z + ";\n");
Console.WriteLine("VR = "
+ Equations.VR + "; Vtheta = "
+ Equations.Vtheta + "; Vz = " + Equations.Vz + ";
h = " + h + "\n");
Console.ReadKey();
while (Period <= 150) // T
{
xCoord = RK4.Y[0] * Math.Cos(RK4.Y[1]);
yCoord = RK4.Y[0] * Math.Sin(RK4.Y[1]);
Period = DoublePeriod / 2;
Energy = (RK4.Y[3] * RK4.Y[3] + RK4.Y[4]
* RK4.Y[4] + RK4.Y[5] * RK4.Y[5]) / 2.0;
locError = Math.Abs((Energy - Energy0) / Energy0);
energy.WriteLine("{0}\t{1}",
ptime.ToString().Replace(,,.),
40

Energy.ToString().Replace(,,.).Replace(E,e));
error.WriteLine("{0}\t{1}", ptime.ToString().Replace(,,.),
locError.ToString().Replace(,,.).Replace(E,e));
data.WriteLine("{0}\t{1}",
RK4.Y[0].ToString().Replace(,,.),
RK4.Y[1].ToString().Replace(,,.)); // t, y, y
Cartesian.WriteLine("{0}\t{1}",
xCoord.ToString().Replace(,,.),
yCoord.ToString().Replace(,,.));
Console.WriteLine(DoublePeriod + \n);
RK4.NextStep(h);
if (Math.Round(RK4.Y[0], 2) == 0.0) // ""
DoublePeriod += 1.0;
}
data.Close(); //
energy.Close();
error.Close();
Cartesian.Close();
Console.WriteLine("Done!");
data.Dispose(); //
energy.Dispose();
error.Dispose();
Cartesian.Dispose();
}
}
}

41