handybeam.world

Describes the virtual world, in which the acoustic propagation occurs.

Holds a description of things like:

  • Environment properties, like wave velocity, temperature, e.t.c.

    • Note, over time i might extend this with pressure and temperature
  • The list of samplers (objects that describe how to sample the acoustic field)

  • The transmitter array (object that describes the Tx Array)

  • The propagator (object that holds the propagation engine, and compute resources)

Todo

Replace all “if print feedback” with a logging module. Time to grow up. See this tutorial

class handybeam.world.World(frequency=40000, sound_velocity=343, use_device=0, use_platform=0)[source]

Root descriptor of the simulated universe

Contains what is needed to quickly serve typical use cases for HandyBeam.

Example use:

world=handybeam.world.World()
world.tx_array = handybeam.tx_array_library.rectilinear(parent = world)
rectilinear_sampler = world.add_sampler(handybeam.samplers.rectilinear_sampler.RectilinearSampler(parent=world))

Note

Note that OpenCL kernels are compiled with sound velocity and frequency as constants. This is for performance purposes.

sound_velocity

Sound velocity. Set only via creating a new world.

Type:numpy.float
frequency

fundamental frequency of operation for the transmitter array. Set only via creating a new world.

Type:numpy.float
medium_wavelength

computed wavelength for this world. constant.

Type:numpy.float
medium_wavenumber

computed wavenumber for this world. constant.

Type:numpy.float
samplers

list of the field sampler objects.

Type:list[handybeam.samplers.*]
tx_array

the transmitter array object.

Type:handybeam.tx_array.TxArray
propagator

the object that holds the OpenCL code for calculating (propagating) the acoustic field.

Type:handybeam.opencl_wrappers.propagator_wrappers.Propagator
platform

OpenCL platform ID

Type:int
device

OpenCL device ID

Type:int
__init__(frequency=40000, sound_velocity=343, use_device=0, use_platform=0)[source]

instance constructor.

Upon creation, add an example array, initialize the propagator, and have no samplers.

the user must add a field sampler.

At one point, I tried to make it to auto-give itself a default sampler, but that resulted in circular references. Possibly I can find a workaround to that later on.

__repr__()[source]

links back to __str__()

__str__()[source]

returns a short info about this world.

_check_existence_after_creation()

Helper function for RememberInstanceCreationInfo

Returns:raises an error if the object’s data is not found
_repr_html_()[source]

builds a html version of the repr. Displays some basic properties about this world instance.

Returns:Jupyter/IPython uses this
add_sampler(sampler=None)[source]

Adds a new field sampler to the world

rectilinear_sampler = world.add_sampler(handybeam.samplers.rectilinear_sampler.RectilinearSampler(parent=world))
Parameters:sampler (handybeam.samplers.*) – the sampler instance to add
Returns:handle to the new sampler instance
print_debug_creation_info()

helper method of RememberInstanceCreationInfo

Returns:prints the debug data
propagate(print_performance_feedback=False)[source]

Shortcut: Ask all the field samplers to execute it’s propagator

calls sampler.propagate(...) of each sampler in the samplers list

Parameters:print_performance_feedback – if set to True, will print feedback to console
Returns:Nothing
visualise(colour_scale=None)[source]

Shortcut: Ask all the field samplers to execute it’s visualizer

calls sampler.visualize(...) for all samplers in the samplers list

Parameters:color_scale – if set, use that color scale. Usefull if you want all the plots to use a common color scale.
handybeam.world.tau = 6.283185307179586

the tau constant. It really should get implemented into numpy.


Back to Welcome

Licence (documentation): Creative Commons CC BY-NC-SA 4.0

Licence (source code): Apache 2.0

EU logo

This project has received funding from the European Union’s Horizon 2020 research and innovation programme under grant agreement No 737087.


This project has received funding from Ultrahaptics.

Ultrahaptics logo