-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathsimple_monte_carlo.zig
More file actions
52 lines (41 loc) · 1.58 KB
/
Copy pathsimple_monte_carlo.zig
File metadata and controls
52 lines (41 loc) · 1.58 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
43
44
45
46
47
48
49
50
51
52
const std = @import("std");
const astroz = @import("astroz");
const MonteCarlo = astroz.MonteCarlo;
const constants = astroz.constants;
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
std.debug.print("=== Simple Monte Carlo Test ===\n", .{});
// Basic uncertainty configuration
const uncertainty = MonteCarlo.UncertaintyParams{
.departureRadiusUncertainty = 0.01, // 1%
.arrivalRadiusUncertainty = 0.01, // 1%
.muUncertainty = 0.001, // 0.1%
.launchWindowDays = 1.0,
.measurementNoise = 0.001,
};
const config = MonteCarlo.MonteCarloConfig{
.numSimulations = 1000,
.uncertainty = uncertainty,
.seed = 42,
.departureBody = constants.earth,
.arrivalBody = constants.mars,
.baseMu = constants.sun.mu,
};
var mc = MonteCarlo.init(allocator, config);
defer mc.deinit();
std.debug.print("Running {d} Earth-Mars Hohmann transfer simulations...\n", .{config.numSimulations});
try mc.runHohmannSimulation();
std.debug.print("Simulation completed!\n", .{});
try mc.printStatistics();
std.debug.print("\nFirst 3 simulation results:\n", .{});
for (mc.results.items[0..@min(3, mc.results.items.len)], 0..) |result, i| {
std.debug.print(" {d}: deltaV={d:.3} km/s, time={d:.1} days\n", .{
i + 1,
result.deltaV,
result.transferTime,
});
}
std.debug.print("\n=== Monte Carlo Test Complete ===\n", .{});
}