Skip to content

add support for `bamps` code

Florian Atteneder requested to merge fa/add-bamps-code into master

About the bamps file format

IIUC all file formats currently supported by watpy store the psi4 data as a triple of (t,real,imag) data and it is assumed that one file contains one mode extracted at one radius.

On the other, in bamps psi4 we write a file for each mode that contains all the radii at which psi4 is computed during the simulation. In particular, the header of an output file contains a list of radii.

Because of that I decided to implement the reader as follows: Given a bamps output file Psi4_20, a user must append the radius index from the header to the filename that is passed to wave. To ease the extraction of the radii list I added the wfile_get_all_detrads_bamps function (see example below).

Also: I did not yet bother to implement support for mwaves, because there seems to be few bugs. Will open separate issues for those. Nevermind, all looks fine and mwaves should just work when passed in a list of file names with the correct indices appended.

Example

With the changes of this PR the following script can reproduce the waveform from fig 10 form this paper here: https://arxiv.org/pdf/2311.16251.pdf (sorry, can't attach data file, because it is +50M and can only upload 10M here ...)

#!/usr/bin/env python3

import os
import numpy as np
from watpy.wave.wave import wave
from watpy.wave.wave import wfile_get_detrad_bamps, wfile_get_all_detrads_bamps
import matplotlib.pyplot as plt


M = 0.79
r = 720.0
fname = "/ssd2/du23lag/data/project_boson_star_headon/longruns/cts_helfer_v_0.05/p17/output_spheres/Psi4_20"
rs = wfile_get_all_detrads_bamps(fname)
print(rs)
idx = rs.index(r)
fname_i = f"{fname}_{idx}"
path = os.path.dirname(fname)

w = wave(path, 'bamps', fname_i, mass=M, f0=0.00002) # frequency is just dummy value
print(w.prop)
plt.plot(w.time / M, np.real(w.p4) * M * r)
plt.show(block=True)

cc @haruet

Edited by Florian Atteneder

Merge request reports