-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.php
More file actions
42 lines (32 loc) · 1.11 KB
/
main.php
File metadata and controls
42 lines (32 loc) · 1.11 KB
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
<?php
require __DIR__ . '/vendor/autoload.php';
use Phpysics\Particle;
use Phpysics\FixedPoint;
use Phpysics\Coordinate;
use Phpysics\Velocity;
use Phpysics\System;
use IO\FileOutput;
$cell = [];
$config_file = $argv[1] ?? 'configs/config.php';
$config = require __DIR__ . '/' . $config_file;
$particles = [];
foreach ($config['particles'] as $p) {
$coordinate = new Coordinate($p['x'], $p['y'], $p['z']);
$velocity = new Velocity($p['vx'], $p['vy'], $p['vz']);
$particle = new Particle($p['mass'], $coordinate, $velocity);
$particles[] = $particle;
}
$fixed_points = [];
if (isset($config['fixed_points'])) {
foreach ($config['fixed_points'] as $f) {
$coordinate = new Coordinate($f['x'], $f['y'], $f['z']);
$fixed_point = new FixedPoint($f['mass'], $coordinate);
$particles[] = $fixed_point;
}
}
$system = new System($particles, $config['constants'], $config['boundary']);
$output_file = 'data.json';
file_put_contents($output_file, '');
$steps = $config['steps'] ?? 100;
$interval = $config['interval'] ?? 1;
$system->calculate($steps, new FileOutput($output_file), $interval);