Setting up a free field simulation
The workflow of the free field simulation is conceptually similar to that of creating an ordinary simulation. See the details in the steps below.
In a free field simulation the goal is to model the radiation characteristics of a device in anechoic conditions. It is therefore expected that the input to the simulation is a geometry of a device with one of its surfaces specified as the radiating surface, such as a loudspeaker membrane via the boundary_velocity
sourcetype and extracting the far field radiation characteristics of the source as a whole. The aim with this simulation type is to automate most of the pre- and post-processing of such an analysis. The free field simulation utilizes the same dg
time domain solution of the acoustic wave-equation as our ordinary simulations providing a smooth solution of the response at all frequencies within the simulations frequency range.
Creating the free field model
To create model for a free field simulation, use ff.add_free_field_model()
. This function will automatically create a ModelObj
in the specified project that is prepared specifically for free field simulations. The input geometry can either be created using the GeometryDefinition
or imported directly from any of the supported file types in the treble SDK. During the model creation, a spherical surface is added around the device to bound the simulation and enable setting up the anechoic condition. See the example below of using the GeometryComponentGenerator
to create a generic loudspeaker model
geometry = treble.GeometryComponentGenerator.create_loudspeaker(
width=0.15,
depth=0.15,
height=0.15,
membrane_diameter=0.05,
membrane_center_height=0.075,
)
ff_model = ff.model.add_free_field_model(
project=p, name="test", geometry=geometry
)
Once the model has been created, it can be visualized using the .plot()
method. The model object is added into the specified project, so it can at any time be fetched again from the Project
using the .get_models()
or other query methods on the project.
Creating the free field simulation definition
The next step is to create a ff.FreeFieldSimulationDefinition
that defines the free field simulation. This is conceptually similar to the creation of an ordinary simulation, but the arguments are specialized towards the automatic setup of the free field simulation.
When creating a ff.FreeFieldSimulationDefinition()
a definition of a simulation is created that allows for validation of inputs either automatically or by manual inspection. At this point the simulation is not yet added to the project and can be considered a "draft" state of the simulation. The free field simulation automates the setup of a simulations with the following configuration already set:
- Places a grid of receivers in the given sphere radius around the origin
- Assigns the Boundary Velocity Source and will therefore only be running a wavebased simulation.
- The free field simulation automatically assigns a fully reflective material to all device surfaces, and the exterior spherical surface with an absorbing condition.
- Sets the IR length exactly short enough to remove any reflections that may be coming from the exterior domain, thereby obtaining an anechoic condition.
Use the .plot()
method to review of the geometry, source assignment, receiver placements and material assignment.
The simulation definition takes the upper_frequency
as one of the main inputs. The simulation is performed in the time-domain and the upper frequency is used to define the valid frequency range of the result. i.e. the mesh sizing and the input signal is limited by this input. See the details of the input in the Boundary Velocity.
Adding the definition to the project
Once the simulation definition has been validated, the next step is then to add the definition to the project to create the simulation in the user/organization database. When doing this step, the volumetric meshing process starts. Add the definition to the project using project.add_simulation(free_field_simulation_definition)
.
Once the meshing step is completed use the dd.display(simulation.get_mesh_info())
to display information about the mesh and simulation.get_mesh_info().plot()
to plot the surface mesh. See TODO: meshing tips and tricks for knowledge on how to optimize the meshing process.
The simulation can then be run as an ordinary simulation using the simulation.start()
method.