Note
Click here to download the full example code
Custom source
Note
NDK and its examples are under constant development, more information and content will be added to this example soon!
This example demonstrates how to add a source to the simulation.
A Source receives the following parameters:
- position
(npt.NDArray[np.float_])
: a numpy float array indicating the coordinates (in meters) of the point at the center of the source. - direction
(npt.NDArray[np.float_])
: a numpy float array representing a vector located at position and pointing towards the focal point. Only the orientation ofdirection
affects the source, the length of the vector has no affect. See theunit_direction
property. - aperture
(float)
: the width (in meters) of the source. - focal_length
(float)
: the distance (in meters) fromposition
to the focal point. - num_points
(int)
: the number of point sources to use when simulating the source. - delay
(float, optional)
: the delay (in seconds) that the source will wait before emitting. Defaults to 0.0.
import neurotechdevkit as ndk
source = ndk.sources.FocusedSource2D(
position=[0.00, 0.0],
direction=[0.9, 0.0],
aperture=0.01,
focal_length=0.01,
num_points=1000,
)
scenario = ndk.built_in.Scenario0()
scenario.sources = [source]
scenario.make_grid()
scenario.compile_problem()
result = scenario.simulate_steady_state()
assert isinstance(result, ndk.results.SteadyStateResult2D)
result.render_steady_state_amplitudes()
Out:
Estimated time to complete simulation: 44 seconds. Memory required is 8.09906664298232 GB (available 73.624051712 GB). These values are approximated.
/home/circleci/.cache/pypoetry/virtualenvs/neurotechdevkit-3aSsmiER-py3.10/lib/python3.10/site-packages/devito/finite_differences/differentiable.py:224: DeprecationWarning: NotImplemented should not be used in a boolean context
return super(Differentiable, self).__eq__(other) and\
/home/circleci/.cache/pypoetry/virtualenvs/neurotechdevkit-3aSsmiER-py3.10/lib/python3.10/site-packages/devito/finite_differences/differentiable.py:224: DeprecationWarning: NotImplemented should not be used in a boolean context
return super(Differentiable, self).__eq__(other) and\
gcc -O3 -g -fPIC -Wall -std=c99 -march=native -Wno-unused-result -Wno-unused-variable -Wno-unused-but-set-variable -ffast-math -shared -fopenmp /tmp/devito-jitcache-uid1001/4f8ef5056730ae3c7fbdc107b4e51890098e4f0b.c -lm -o /tmp/devito-jitcache-uid1001/4f8ef5056730ae3c7fbdc107b4e51890098e4f0b.so
Total running time of the script: ( 0 minutes 19.399 seconds)
Download Python source code: plot_adding_custom_source.py