Skip to content

acwen11/SimFlightSim

 
 

Repository files navigation

SimFlightSim

Utilities and interface for visualizing Cactus simulation data using the Unity Game Engine. Originally derived from Sebastian Lague's Marching Cubes project. Check out his video and code.

Using the Cactus reader:

The script for preprocessing 3D Carpet HDF5 data can be found in Utils/save_resampled_grid_data.py. This relies on kuibit.

Run the script by using:

python save_resampled_grid_data.py --datadir (sim directory) --pickle-file (optional kuibit pickle file) --variable (grid variable to export) --iteration (iteration to export) --dataout (name of output files) -x0 (origin of export domain; x, y, z) -x1 (corner of export domain; x, y, z) --numchunks (chunk configuration; x, y, z)

Example

The script essentially interpolates 3D data to $128^3$ point cubes, or "chunks". x0 and x1 set the size of the region to be exported, and numchunks sets the resolution of export data. For example:

python save_resampled_grid_data.py --datadir myBNSRun --variable rho --iteration 102400 --dataout bns_MR -x0 -100 -100 -50 -x1 100 100 50 --numchunks 2 2 1

exports rho at iteration 102400 and stores exported data in a directory named bns_MR. Exported data will divide a domain of $x \in [-100, 100]; y \in [-100, 100]; z \in [-50, 50]$ into $2 \times 2 \times 1$ chunks, such that the final uniform grid has $256 \times 256 \times 128$ points. Each chunk must have the same size and grid spacing. In this case, each chunk covers a volume of $100^3$ code units and has a grid spacing of $100/128$ code units.

After running save_resampled_grid_data, move the directory containing generated files to Assets/SimData. To render this data, enter the dataout name in the "Sim Name" text input field in the game Options menu.

Adding Gravity

You can add point masses that interact with the player in game. This information is provided in the (dataout)/(dataout)_pars.txt file generated by the script. For each neutron star, add a line

NSInfo: (Mass) (x) (y) (z)

where x, y, and z are the coordinates of the point mass in code units. The mass can be given in code units, although the "gravitational force" is currently a bit ad hoc, taking the player's mass to be 0.01 M. For a black hole, you can also set an "event horizon" radius, which will just be a black sphere generated in game:

BHInfo: (Mass) (Horizon radius) (x) (y) (z)

About

Fly a spaceship inside an ETK simulation?

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 75.3%
  • ShaderLab 19.5%
  • HLSL 3.3%
  • Python 1.9%