NetworkLoader
- class sharpy.io.network_interface.NetworkLoader[source]
SHARPy UDP data input and output interface.
The settings of this interface are to be used as the dictionary to the setting
network_setting
in theDynamicCoupled
solver, which is the only one that is currently supported.This interface allows for SHARPy to receive and send simulation data over the network using an UDP protocol.
The setting
variables_filename
is a filename to aYAML
file that contains a list of the input or output variables. The example below shows an acceptable input--- - name: 'control_surface_deflection' # variable name. those in the timestep_info are supported var_type: 'control_surface' inout: 'in' # either `in`, `out` or `inout` position: 0 # control surface index - name: 'pos' # variable name var_type: 'node' # type of variable. In this case a node variable. Others: `panel`, `control_surface` inout: 'out' position: 5 # node number index: 2 # vector index, in this case a 3d vector where the desired index is number 2 - name: 'gamma' inout: 'out' position: [0, 1, 2] # [i_surf, i_chordwise, i_spanwise] var_type: 'panel' - name: 'psi' # CRV inout: 'out' var_type: 'node' position: 3 # node id index: 2 # dimension index ...
All variables in the aero and structural timestep info classes
datastructures
are supported, with the addition ofdt
for the time increment andnt
for the current time step number.Note
If using a control surface input, make sure this control surface is given
control_surface_type = 2
in the the case.aero.h5
file. Otherwise, the control surface will not move!The relevant settings for the input and output sockets can be found in
InNetwork
andOutNetwork
, respectively.If the setting
send_output_to_all_clients
isTrue
, then the clients from which the input signal is received will also be added to the destination client address book.The input and output messages follow the example set by X-Plane
RREF0
protocol. Thus, a message consists of a 5-byte header containingRREF0
followed by 8-bytes per variable, where the first 4-bytes correspond to the variable number (as ordered in the YAML file) as an integer and the latter 4-bytes correspond to the value of the variable in single precision float. The byte ordering is specified by the user.A specific network log is created to detail the ins and outs of the communication protocol. The level of messages that are shown can be set in the settings.
See also
Endianness: https://docs.python.org/3/library/struct.html#byte-order-size-and-alignment
Note
The SHARPy input and output sockets do not time out.
Note
The first time step in a simulation with UDP inputs takes particularly long. Make sure your client has a sufficient time out time to avoid issues. After the first time step, the UDP should not delay the simulation.
Warning
There is a limitation, for the moment, on just one control surface being supported for UDP input.
The
NetworkLoader
takes the following settings:Name
Type
Description
Default
variables_filename
str
Path to YAML file containing input/output variables
None
byte_ordering
str
Desired endianness byte ordering
little
input_network_settings
dict
Settings for the input network.:class:~sharpy.io.network_interface.InNetwork.
{}
output_network_settings
dict
Settings for the output network
OutNetwork
.{}
send_output_to_all_clients
bool
Send output to all clients, including those from where the input is received.
False
received_data_filename
str
If not empty, writes received input data to the specified file.
log_name
str
Network log file name
./network_output.log
console_log_level
str
Minimum logging level in console.
info
file_log_level
str
Minimum logging level in log file.
debug