netsse.simul.ship_resp#
Numerical simulation of ship responses.
Copyright (C) 2023-2026 Technical University of Denmark, R.E.G. Mounet
This code is part of the NetSSE software.
NetSSE is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
NetSSE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
To credit the author, users are encouraged to use below reference:
Mounet, R. E. G., & Nielsen, U. D. NetSSE: An open-source Python package
for network-based sea state estimation from ships, buoys, and other
observation platforms (version 2.2). Technical University of Denmark,
GitLab. February 2026. https://doi.org/10.11583/DTU.26379811.
Last updated on 20-02-2026 by R.E.G. Mounet
Attributes#
Classes#
This constructor should always be called with keyword arguments. Arguments are: |
Functions#
A function to process the FIFO queue. |
|
|
Generates several time histories of the waves encountered by a ship and, |
|
Performs the summation of the sine components to simulate in the time domain |
Module Contents#
- class netsse.simul.ship_resp.MultiThread(name)[source]#
Bases:
threading.ThreadThis constructor should always be called with keyword arguments. Arguments are:
group should be None; reserved for future extension when a ThreadGroup class is implemented.
target is the callable object to be invoked by the run() method. Defaults to None, meaning nothing is called.
name is the thread name. By default, a unique name is constructed of the form “Thread-N” where N is a small decimal number.
args is a list or tuple of arguments for the target invocation. Defaults to ().
kwargs is a dictionary of keyword arguments for the target invocation. Defaults to {}.
If a subclass overrides the constructor, it must make sure to invoke the base class constructor (Thread.__init__()) before doing anything else to the thread.
- run()[source]#
Method representing the thread’s activity.
You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.
- netsse.simul.ship_resp.process_queue()[source]#
A function to process the FIFO queue.
This basic function runs the function
netsse.simul.ship_resp.sum_components()with the queued arguments, until the queue is empty, after which it signals that the task is completed.See also
- netsse.simul.ship_resp.simul_ship_resp(S2D, freq_wave, betas_wave, U=0, RespStr='Waves', max_threads=0, freq_TRF=[0], betas_TRF=0, TRF_amps=0, TRF_phases=0, NoTs=10, fs=10, T=30 * 60, Nomega=500, AddNoise=False, snr=20)[source]#
Generates several time histories of the waves encountered by a ship and, optionally, the wave-induced vessel motion responses (heave, roll, pitch).
A 2D wave spectrum must be given as input. If ship response is to be simulated too, then the wave-to-motion transfer functions of the vessel must also be provided.
- Parameters:
S2D (array_like of shape (Nf_wave,Nmu)) – 2-D wave spectrum characterizing the sea state [m^2.s.s/rad].
freq_wave (array_like of shape (Nf_wave,)) – Vector of wave frequencies [Hz] in which the wave spectrum is expressed.
betas_wave (array_like of shape (Nmu,)) –
Vector of the relative wave headings [deg] for the wave spectrum.
Note
The relative wave headings are defined as: 0 deg: following sea; 90 deg: beam waves from port side; 180 deg: head sea; 270 deg: beam waves from starboard side.
U (float, default 0) – Vessel speed [m/s].
RespStr ({'Waves','Motions'}, optional) – Use
'Motions'if vessel motions in waves are also to be simulated (in addition to the waves). Otherwise, use'Waves'and only the wave surface elevation will be simulated. The default is'Waves'.max_threads (int, default 0) –
Indicates to maximum number of threads to be used to parallelize the execution.
Attention
A large value for
max_threadsshould only be used if the program is run on a high-performance computer. The code execution risks crashing otherwise.freq_TRF (array_like of shape (Nf_TRF,), default [0,]) – Vector of wave frequencies [Hz] in which the transfer functions are expressed.
betas_TRF (array_like of shape (Nbeta,), default 0) – Vector of the relative wave headings [deg] indicating the direction of propagation of the energy (relative to vessel heading) for the transfer functions.
TRF_amps (array_like of shape (Nf_TRF, Nbeta, 3), optional) – The amplitude of the transfer functions for heave, roll, and pitch, respectively. The default is 0.
TRF_phases (array_like of shape (Nf_TRF, Nbeta), optional) – The phase of the transfer functions for heave, roll, and pitch, respectively. The default is 0.
NoTs (int, default 10) – Number of time series to be generated.
fs (float, default 10) – Sampling frequency [Hz] for the generated time histories.
T (float, optional) – Duration [s] of the time histories. The default is 30*60 = 1800 s.
Nomega (int, default 500) – Number of wave components used for each direction to generate the time histories.
AddNoise (bool, default False) – A boolean that indicates whether random noise (Gaussian white noise) is added to be added the motion time histories.
snr (float, default 20) – The signal-to-noise ratio to be used for addition of noise.
- Returns:
time (array_like of shape (T*fs,).) – Vector of time [s].
wavet (array_like of shape (NoTs,T*fs).) – Wave elevation [m] time series.
heavet, rollt, pitcht (array_like of shape (NoTs,T*fs).) – Heave, roll and pitch time series.
Note
heavet,rollt,pitchtare returned if and only if RespStr ='Motions'
See also
sum_componentsPerforms the summation of the sine components to simulate in the time domain the encountered wave elevation or the wave-induced responses on a ship.
Example
>>> # Wave simulations >>> time, wavet = ... simul_ship_resp(S2D,freq_wave,betas_wave,U,'Waves',0,NoTs=10,fs=10,T=30*60, ... Nomega=500,AddNoise=True,snr=20) >>> # Motion simulations >>> time, wavet, heavet, rollt, pitcht = ... simul_ship_resp(S2D,freq_wave,betas_wave,U,'Motions',0,freq_TRF,betas_TRF, ... TRF_amps,TRF_phases,NoTs,fs,T,Nomega,AddNoise=True,snr=20)
- netsse.simul.ship_resp.sum_components(aw, V_seed, W_seed, epsilon_seed, om_enc, time, seed, result, TRF_amps=0, TRF_phases=0, RespStr='Waves', AddNoise=False, snr=20)[source]#
Performs the summation of the sine components to simulate in the time domain the encountered wave elevation or the wave-induced responses on a ship.
- Parameters:
aw (array_like of shape (Nfreq,Nbeta,1)) – Amplitude of the wave components.
V_seed (array_like of shape (Nfreq,Nbeta,1)) – Standard normal distributed variables with mean 0 and std. 1.
W_seed (array_like of shape (Nfreq,Nbeta,1)) – Standard normal distributed variables with mean 0 and std. 1.
epsilon_seed (array_like of shape (Nfreq,Nbeta,1)) – Random phases [rad] of the wave components. Those are uniformly distributed variables between 0 and \(2\pi\).
om_enc (array_like of shape (Nfreq,1,1)) – Vector of encounter wave frequencies [rad/s].
time (array_like of shape (1,1,Nt)) – Vector of time [s].
seed (int) – Index of the seed number.
result (array_like of shape (Nseed,Nt)) –
Anterior value of the vector of wave/response sequence.
Note
Consult the documentation of the
netsse.simul.ship_resp.simul_ship_resp()function for information on the other parameters.
- Returns:
result – Updated value of the vector of wave/response sequence.
- Return type:
array_like of shape (Nseed,Nt)
See also