Skip to content

Commit

Permalink
Improve ProStudio model
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiashienzsch committed Sep 8, 2024
1 parent bcd6727 commit 3dc7a5b
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 21 deletions.
4 changes: 2 additions & 2 deletions data/models/ProStudio/ProStudio_cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
duration=1.2,
Tc=20,
rh=50,
fcc_flag=False,
fcc_flag=True,
PPW=10.5,
fmax=800.0,
save_folder='../../sim_data/ProStudio/cpu',
save_folder_gpu='../../sim_data/ProStudio/gpu',
# save_folder_gpu='../../sim_data/ProStudio/gpu',
draw_vox=True,
draw_backend='polyscope',
compress=0,
Expand Down
12 changes: 8 additions & 4 deletions data/models/ProStudio/ProStudio_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import numpy as np

from pffdtd.sim3d.constants import SimConstants
from pffdtd.sim3d.room_builder import find_third_vertex


Expand Down Expand Up @@ -90,7 +91,10 @@ def main():
dir = pathlib.Path(".")
obj = dir/"obj"

offset = 0.07
fcc = True
constants = SimConstants(Tc=20, rh=50, fmax=800, PPW=10.5, fcc=fcc)
mul = 4.0 if fcc else 2.0
offset = constants.h * mul

s1 = [3.38789-3.288/2, 6.90-offset, 1.062+0.332]
sub1 = s1.copy()
Expand Down Expand Up @@ -142,9 +146,9 @@ def main():
m.add("Windows", obj / 'windows.obj', [137, 207, 240], reverse=True)
m.add_source("S1", s1)
m.add_source("S2", s2)
m.add_source("S3", s3)
m.add_source("SUB1", sub1)
m.add_source("SUB2", sub2)
# m.add_source("S3", s3)
# m.add_source("SUB1", sub1)
# m.add_source("SUB2", sub2)
m.add_receiver("R1", r1)
m.add_receiver("R2", r2)
m.add_receiver("R3", r3)
Expand Down
2 changes: 1 addition & 1 deletion data/models/ProStudio/model.json

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions run_3d.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -e
root_dir="$(cd "$(dirname "$0")" && pwd)"
engine_exe="$root_dir/build/src/cpp/main_3d/pffdtd_3d"

sim_name="Modes"
sim_name="ProStudio"
sim_setup="${sim_name}_cpu.py"
sim_model_gen="${sim_name}_model.py"
sim_dir="$root_dir/data/sim_data/$sim_name/cpu"
Expand All @@ -32,13 +32,13 @@ python "$sim_setup"
$engine_exe "$sim_dir"

# Post-process
pffdtd sim3d process-outputs --sim_dir="$sim_dir" --fcut_lowpass "$fmax" --order_lowpass=8 --symmetric_lowpass --fcut_lowcut "$fmin" --order_lowcut=4 --air_abs_filter="none" --save_wav --plot
# pffdtd analysis response --fmin=10 --target="-2.5" --smoothing=$smoothing --fmax=$fmax $sim_dir/R001_out_normalised.wav $sim_dir/R002_out_normalised.wav
# pffdtd analysis response --fmin=10 --target="-2.0" --smoothing=$smoothing --fmax=$fmax $sim_dir/R001_out_normalised.wav $sim_dir/R003_out_normalised.wav
# pffdtd analysis response --fmin=10 --target="-1.5" --smoothing=$smoothing --fmax=$fmax $sim_dir/R001_out_normalised.wav $sim_dir/R004_out_normalised.wav
# pffdtd analysis response --fmin=10 --target="-1.0" --smoothing=$smoothing --fmax=$fmax $sim_dir/R001_out_normalised.wav $sim_dir/R005_out_normalised.wav
# pffdtd analysis response --fmin=10 --target="-0.5" --smoothing=$smoothing --fmax=$fmax $sim_dir/R001_out_normalised.wav $sim_dir/R006_out_normalised.wav
# pffdtd analysis waterfall $sim_dir/R001_out_normalised.wav
# pffdtd analysis t60 --fmin=$fmin --fmax="$fmax" --target=0.3 $sim_dir/R001_out_normalised.wav
# pffdtd analysis t60 --sim_dir="$sim_dir" --fmin=$fmin --fmax="$fmax" --target=0.25
pffdtd analysis room-modes --sim_dir="$sim_dir" --fmin=$fmin --fmax=$fmax --num_modes=20 --width=2.0 --length=3.0 --height=4.0
pffdtd sim3d process-outputs --sim_dir="$sim_dir" --fcut_lowpass "$fmax" --order_lowpass=8 --symmetric_lowpass --fcut_lowcut "$fmin" --order_lowcut=4 --air_abs_filter="stokes" --save_wav --plot
pffdtd analysis response --fmin=10 --target="-2.5" --smoothing=$smoothing --fmax=$fmax $sim_dir/R001_out_normalised.wav $sim_dir/R002_out_normalised.wav
pffdtd analysis response --fmin=10 --target="-2.0" --smoothing=$smoothing --fmax=$fmax $sim_dir/R001_out_normalised.wav $sim_dir/R003_out_normalised.wav
pffdtd analysis response --fmin=10 --target="-1.5" --smoothing=$smoothing --fmax=$fmax $sim_dir/R001_out_normalised.wav $sim_dir/R004_out_normalised.wav
pffdtd analysis response --fmin=10 --target="-1.0" --smoothing=$smoothing --fmax=$fmax $sim_dir/R001_out_normalised.wav $sim_dir/R005_out_normalised.wav
pffdtd analysis response --fmin=10 --target="-0.5" --smoothing=$smoothing --fmax=$fmax $sim_dir/R001_out_normalised.wav $sim_dir/R006_out_normalised.wav
pffdtd analysis waterfall $sim_dir/R001_out_normalised.wav
pffdtd analysis t60 --fmin=$fmin --fmax="$fmax" --target=0.3 $sim_dir/R001_out_normalised.wav
pffdtd analysis t60 --sim_dir="$sim_dir" --fmin=$fmin --fmax="$fmax" --target=0.25
# pffdtd analysis room-modes --sim_dir="$sim_dir" --fmin=$fmin --fmax=$fmax --num_modes=20 --width=2.0 --length=3.0 --height=4.0
3 changes: 1 addition & 2 deletions src/python/pffdtd/analysis/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@ def main(filename, fmin, fmax, label_a, label_b, smoothing, target):
fs_b, buf_b = wavfile.read(file_b)

assert fs_a == fs_b
assert buf_a.shape == buf_b.shape

fmax = fmax if fmax != 0.0 else fs_a/2
nfft = 2**iceil(np.log2(buf_a.shape[0]))
nfft = 2**iceil(np.log2(max(buf_a.shape[0], buf_b.shape[0])))
freqs = np.fft.rfftfreq(nfft, 1/fs_a)

spectrum_a = np.fft.rfft(buf_a, nfft)
Expand Down
10 changes: 9 additions & 1 deletion src/python/pffdtd/sim3d/room_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,15 @@ def draw(self,backend='mayavi',plot_normals=False,wireframe=False):
else:
color = tuple(npa(mats_dict[mat]['color'])/255.0)

ps.register_surface_mesh(mat, pts, tris,color=color,edge_color=(0,0,0),edge_width=1)
ps.register_surface_mesh(
name=mat,
vertices=pts,
faces=tris,
color=color,
edge_color=(0,0,0),
edge_width=1,
enabled=False,
)

else:
raise
Expand Down

0 comments on commit 3dc7a5b

Please sign in to comment.