File: check-minkowski.i

package info (click to toggle)
gyoto 1.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 8,588 kB
  • sloc: cpp: 33,490; sh: 18,775; xml: 2,633; python: 1,424; makefile: 681; ansic: 314
file content (129 lines) | stat: -rw-r--r-- 3,582 bytes parent folder | download | duplicates (11)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
    Copyright 2014 Thibaut Paumard

    This file is part of Gyoto.

    Gyoto is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Gyoto is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Gyoto.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "check-helpers.i"

// There is no specific Yorick interface for the Minkowski metric.
// The only limitation is that is is not possible to retrieve the kind
// of coordinate system in use.

restore, gyoto;

begin_section, "Minkowski metric", "in cartesian coordinates";

positions=[[0, 10., 12., 5.],
           [0, 5., 2., 7.],
           [0, -10., 0., 50.],
           [0, 0., 0., 10000.]];

doing, "creating Minkowski metric";
gg=Metric("Minkowski");
done;

check_gmunu, gg, positions;
check_christoffels, gg, positions;

doing, "creating Star in this metric";
st = Star(metric=gg, initcoord=[0., 0., 0., 0.], [0., 0., 0.]);
done;

doing, "integrating geodesic";
st, xfill=1000.;
done;

doing, "checking results";
data=st(get_coord=);
d=dimsof(data);
write, format="(integration produced %d rows)...", d(2);
if (!(allof(data(,2:)==([0., 0, 0, 1., 0, 0, 0](-:1:d(2), )))))
  error, "integration produced wrong results";
done;

doing, "checking another star";
pos=[0., 4., 2., 6.];
vel=[0.5, 0.2, 0.4];
st = Star(metric=gg, initcoord=pos, vel);
st, xfill=1000.;
data=st(get_coord=);
maxerr=max(abs(minmax(data(, 2:4)-data(,1)(,-)*vel(-,)-pos(-,2:4))));
if (maxerr>1e-10) error, "integration produced wrong results";
done;

doing, "checking a photon";
pos=[0., 4., 2., 6.];
vel=[0.5, 0.2, 0.4];
st = Photon(metric=gg, initcoord=pos, vel);
st, xfill=1000.;
data=st(get_coord=);

nrows=dimsof(data)(2);
norm=array(double, nrows);
for(i=1; i<=nrows; ++i)
  norm(i)=gg(scalarprod=data(i, 1:4), data(i, 5:8), data(i, 5:8));
if (max(norm) > 1e-10) "error: norm was not conserved";

maxerr=max(abs(minmax(data(, 2:4)-
                      data(,1)(,-)*vel(-,)/data(,5)(,-)-pos(-,2:4))));
if (maxerr>1e-10) error, "integration produced wrong results";
done;

begin_section, "Minkowski metric", "in spherical coordinates";

doing, "changing coordinate system";
gg, setparameter="Spherical";
done;

positions=[[0, 10., pi/2., 0.],
           [100., 10., pi/4., 2.],
           [1000., 100., 1., 1.]];

check_gmunu, gg, positions;
check_christoffels, gg, positions;

doing, "checking motionless star";
pos=[0., 4., 2., 6.];
vel=[0., 0., 0.];
st = Star(metric=gg, initcoord=pos, vel);
st, xfill=1000.;
data=st(get_coord=);
d=dimsof(data);
write, format="(integration produced %d rows)...", d(2);
if (!(allof(data(,2:)==(_(pos(2:),[1.],vel)(-:1:d(2), )))))
  error, "integration produced wrong results";
done;

doing, "checking moving star";
pos=[0., 10.791, pi/2., 0];
vel=[0., 0., 0.016664];
st = Star(metric=gg, initcoord=pos, vel);
st, adaptive=1;
st, delta=0.1;
st, xfill=1000.;
data=st(get_coord=);

dates=data(,1);
txyz=st(get_cartesian=dates);

d=dimsof(data);
write, format="(integration produced %d rows)...", d(2);
//if (!(allof(data(,2:)==(_(pos(2:),[1.],vel)(-:1:d(2), )))))
//  error, "integration produced wrong results";
done;

end_section, "Minkowski metric";