Use case : Parametric analysis using treble
The treble SDK is very powerful tool to run parametric analysis for sensitivity analysis, speaker placement, and building acoustics. The flexibility of the SDK to enables endless possibilites for this use case. Below is an video the gives an example of how to use the sdk with Rhino grasshopper, and further down the page is an example of paramtetric study when optimizing porous absorber in a model.
Quick parameter study
Evaluate the benefits of different acoustic panels in a meeting room by quickly running simulations with a varying thickness of a porous absorber mounted on a wall.
We start by initiating the Treble SDK and creating a project.
from pathlib import Path
from treble_tsdk.tsdk import TSDK
from treble_tsdk import tsdk_namespace as treble
# Our working directory for tsdk files.
# Defaults to your home directory /tmp/tsdk, feel free to change it to what you like.
base_dir = Path.home() / "tmp" / "tsdk"
base_dir.mkdir(parents=True, exist_ok=True)
tsdk = TSDK()
project = tsdk.get_or_create_project(name="parametric study")
%env TSDK_DASH_PLOTTING=1
== SDK package is up to date ==
Find a meeting room from the geometry database
meeting_room = tsdk.geometry_library.get_dataset(
dataset=treble.GeometryLibraryDataset.meeting_room
)[1]
meeting_room.plot()
meeting_room.layer_names
Assign materials to all the layers in the meeting room except for the Acoustic
one.
material_assignments = [
treble.MaterialAssignment(
"Window", material=tsdk.material_library.search("window")[0]
),
treble.MaterialAssignment(
"Table",
material=tsdk.material_library.search("wood")[0],
scattering_coefficient=0.3,
),
treble.MaterialAssignment(
"Light wall", material=tsdk.material_library.search("gypsum")[0]
),
treble.MaterialAssignment(
"Concrete wall", material=tsdk.material_library.search("concrete")[0]
),
treble.MaterialAssignment(
"Door",
material=tsdk.material_library.search("door")[0],
scattering_coefficient=0.3,
),
treble.MaterialAssignment(
"Ceiling", material=tsdk.material_library.search("concrete")[0]
),
treble.MaterialAssignment(
"Floor", material=tsdk.material_library.search("carpet")[0]
),
treble.MaterialAssignment(
"Chairs",
material=tsdk.material_library.search("Plastic chair")[0],
scattering_coefficient=0.4,
),
treble.MaterialAssignment(
"Monitor",
material=tsdk.material_library.search("glass")[0],
scattering_coefficient=0.3,
),
]
We will test varying thicknesses of porous absorbers and to do so we utilize the porous material building tool in the SDK. First we fit the materials and later we add them to the material database
material_proposals = []
absorber_thicknesses = [10, 50, 100, 200, 300]
for absorber_thickness in absorber_thicknesses:
porous = treble.PorousMaterialBuilderDefinition(
name=f"absorber_{absorber_thickness}mm",
category=treble.MaterialCategory.porous,
flow_resistivity=35_000,
porous_layer_thickness=absorber_thickness,
)
material_proposals.append(
tsdk.material_library.perform_material_fitting(material_definition=porous)
)
materials = []
for material in material_proposals:
materials.append(tsdk.material_library.create(material=material))
Now we have some materials and we can setup the simulations with those materials where for each simulation a different thickness of absorber is placed on the Acoustic
layer in the model
source = treble.Source(
x=3.1, y=1.9, z=1.7, source_type=treble.SourceType.omni, label="s_1"
)
receiver = treble.Receiver(
x=1.0, y=1.0, z=1.2, receiver_type=treble.ReceiverType.mono, label="r_1"
)
simulation_definitions = []
for material, absorber_thickness in zip(materials, absorber_thicknesses):
material_assignment = material_assignments.copy()
material_assignment.append(treble.MaterialAssignment("Acoustic", material=material))
simulation_definition = treble.SimulationDefinition(
name=f"absorber_{absorber_thickness}mm",
simulation_type=treble.SimulationType.hybrid,
model=meeting_room,
crossover_frequency=500,
receiver_list=[receiver],
source_list=[source],
material_assignment=material_assignment,
energy_decay_threshold=35,
)
simulation_definitions.append(simulation_definition)
simulations = project.add_simulations(simulation_definitions)
Start all the simulations and monitor their progress.
for simulation in simulations:
simulation.start()
project.as_live_progress()
We can now gather the results and take a look at the T20 values for example to evaluate the benefits of using such an absorber.
all_results = []
for simulation in simulations:
all_results.append(
simulation.download_results(destination_directory=f"results_{simulation.name}")
)
t20 = {}
for simulation, result in zip(simulations, all_results):
t20[simulation.name] = result.get_acoustic_parameters(source=simulation.sources[0])[
"t20"
]
Finally, we plot the results
import matplotlib.pyplot as plt
freq_bands = [63, 125, 250, 500, 1000, 2000, 4000, 8000]
for simulation in simulations:
plt.plot(freq_bands, t20[simulation.name], label=simulation.name)
plt.legend()
plt.xscale("log")
plt.grid(which="minor")
plt.xlabel("Frequency [hz]")
plt.ylabel("T20 [s]")
plt.title("T20 for various absorption thicknesses")
plt.show()