1
0
Fork 0
fgdata/Aircraft/Generic/JSBSim/Systems/hydrodynamics.xml
Anders Gidenstam 09cdc04e91 Fixed some FPE prone spots in the generic JSBSim hydrodynamics systems.
Signed-off-by: Anders Gidenstam <anders@gidenstam.org>
2016-10-23 00:11:40 +02:00

965 lines
26 KiB
XML

<?xml version="1.0"?>
<!--
Hydrodynamics section for JSBSim.
Copyright (C) 2008 - 2016 Anders Gidenstam (anders(at)gidenstam.org)
This program 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 2 of the License, or
(at your option) any later version.
This program 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, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-->
<system name="hydrodynamics">
<documentation>
This system computes forces and moments due to the hull's interaction
with water, both hydrostatic and hydrodynamic, with respect to the
hydrodynamic reference point (HRP).
The coordinate frame used to define the forces and moments is similar to
the body frame but is always aligned with the water surface (which is
assumed to be horizontal). Forces can also be defined in a "wind" frame.
The forces are split into the channels:
- Fbx - body forward.
- Fby - body right.
- Fbz - local up (the same as -Z in the local frame).
- Drag - opposing the relative water flow.
- Side - 90 degrees right from the relative water flow in the surface plane.
The moments are split into the hydrodynamic body frame channels
(with the same sense as the normal body frame moments):
- Pitch
- Yaw
- Roll
The properties determining the location and orientation of the hull
w.r.t the the water surface and stream are:
- hydro/height-agl-ft - Height of the hydrodynamic reference point
over the water surface.
- hydro/beta-deg - angle between the hull's velocity vector throught
the water and its longitudal axis.
Analogous to aerodynamics/beta-deg.
- hydro/pitch-deg - angle between the hull longitudal axis and the
water surface (ground plane).
- hydro/roll-deg - angle between the hull traverse axis and the
water surface (ground plane).
- hydro/v-fps - The hull's total speed relative the water.
Usage:
Include this system in your aircraft.
Define the following properties in a system of your aircraft:
- Hydrodynamics reference point:
<property value="...">metrics/hydro-rp-x-in</property>
<property value="...">metrics/hydro-rp-y-in</property>
<property value="...">metrics/hydro-rp-z-in</property>
- Functions computing the forces in the hydrodynamic body frame
- hydro/fbx-lbs
- hydro/fby-lbs
- hydro/fbz-lbs
Alternative force inputs in the water frame
- hydro/fdrag-lbs
- hydro/fside-lbs
Unused properties also have to be declared (and set to zero).
- Functions computing the moments in the hydrodynamic body frame.
FIXME: Yaw is applied in the standard body frame.
- hydro/yaw-moment-lbsft
- hydro/pitch-moment-lbsft
- hydro/roll-moment-lbsft
Define the following external forces in the main FDM file of your aircraft:
<force name="hydro-X" frame="LOCAL">
<location unit="M">
{ HRP }
</location>
<direction>
<x> 1.0 </x>
<y> 0.0 </y>
<z> 0.0 </z>
</direction>
</force>
<force name="hydro-Y" frame="LOCAL">
<location unit="M">
{ HRP }
</location>
<direction>
<x> 0.0 </x>
<y> 1.0 </y>
<z> 0.0 </z>
</direction>
</force>
<force name="hydro-Z" frame="LOCAL">
<location unit="M">
{ HRP }
</location>
<direction>
<x> 0.0 </x>
<y> 0.0 </y>
<z>-1.0 </z>
</direction>
</force>
<force name="hydro-pitch[0]" frame="LOCAL">
<location unit="M">
<x> HRP X - 0.3048 </x>
<y> HRP Y </y>
<z> HRP Z </z>
</location>
<direction>
<x> 0.0 </x>
<y> 0.0 </y>
<z>-1.0 </z>
</direction>
</force>
<force name="hydro-pitch[1]" frame="LOCAL">
<location unit="M">
<x> HRP X + 0.3048 </x>
<y> HRP Y </y>
<z> HRP Z </z>
</location>
<direction>
<x> 0.0 </x>
<y> 0.0 </y>
<z>-1.0 </z>
</direction>
</force>
<force name="hydro-yaw[0]" frame="BODY">
<location unit="M">
<x> HRP X </x>
<y> HRP Y - 0.3048 </y>
<z> HRP Z </z>
</location>
<direction>
<x> 1.0 </x>
<y> 0.0 </y>
<z> 0.0 </z>
</direction>
</force>
<force name="hydro-yaw[1]" frame="BODY">
<location unit="M">
<x> HRP X </x>
<y> HRP Y + 0.3048 </y>
<z> HRP Z </z>
</location>
<direction>
<x> 1.0 </x>
<y> 0.0 </y>
<z> 0.0 </z>
</direction>
</force>
<force name="hydro-roll[0]" frame="LOCAL">
<location unit="M">
<x> HRP X </x>
<y> HRP Y - 0.3048 </y>
<z> HRP Z </z>
</location>
<direction>
<x> 0.0 </x>
<y> 0.0 </y>
<z>-1.0 </z>
</direction>
</force>
<force name="hydro-roll[1]" frame="LOCAL">
<location unit="M">
<x> HRP X </x>
<y> HRP Y + 0.3048 </y>
<z> HRP Z </z>
</location>
<direction>
<x> 0.0 </x>
<y> 0.0 </y>
<z>-1.0 </z>
</direction>
</force>
</documentation>
<!-- Inputs -->
<!-- Environment -->
<property value="0.0">hydro/environment/water-level-ft</property>
<property value="1.9736403">hydro/environment/rho-slug_ft3</property>
<property value="1.1302106e-05">hydro/environment/kinematic-viscosity-ft2_sec</property> <!-- Sea water at 20 degC. -->
<property value="0.0">hydro/environment/current-from-north-fps</property>
<property value="0.0">hydro/environment/current-from-east-fps</property>
<property value="40.0">hydro/environment/waves-from-deg</property>
<property value="0.0">hydro/environment/wave-amplitude-ft</property>
<property value="150.0">hydro/environment/wave-length-ft</property>
<!-- Model parameters -->
<!-- HRP location. Must be defined.
- metrics/hydro-rp-x-in
- metrics/hydro-rp-y-in
- metrics/hydro-rp-z-in
- metrics/hydro-beam-ft
- metrics/hydro-length-ft
-->
<!-- Input forces in the hydrodynamic body frame.
All must be defined by the aircraft. -->
<!--
Forces in the hydrodynamic body frame
- hydro/fbx-lbs
- hydro/fby-lbs
- hydro/fbz-lbs
Alternative force inputs in the water frame
- hydro/fdrag-lbs
- hydro/fside-lbs
-->
<!-- Input moments in the hydrodynamic body frame.
FIXME: Yaw is applied in the standard body frame.
- hydro/yaw-moment-lbsft
- hydro/pitch-moment-lbsft
- hydro/roll-moment-lbsft
-->
<channel name="Environment">
<fcs_function name="hydro/environment/rho-lbs_ft3">
<function>
<product>
<value>32.174049</value>
<property>hydro/environment/rho-slug_ft3</property>
</product>
</function>
</fcs_function>
<fcs_function name="hydro/environment/gravity-ft_sec2">
<function>
<quotient>
<property>inertia/weight-lbs</property>
<property>inertia/mass-slugs</property>
</quotient>
</function>
</fcs_function>
</channel>
<channel name="Environment - Waves">
<fcs_function name="hydro/environment/wave/relative-heading-rad">
<description>
The difference in heading between the hull and the wave.
</description>
<function>
<difference>
<sum>
<value>3.1415927</value>
<product>
<value>0.017453293</value>
<property>hydro/environment/waves-from-deg</property>
</product>
</sum>
<property>attitude/psi-rad</property>
</difference>
</function>
</fcs_function>
<fcs_function name="hydro/environment/wave/hull-x-factor">
<description>
The result of dot(Dwave, (1,0)), i.e. the cosine of the angle
between the wave heading and the hull heading.
</description>
<function>
<cos>
<property>hydro/environment/wave/relative-heading-rad</property>
</cos>
</function>
</fcs_function>
<fcs_function name="hydro/environment/wave/hull-y-factor">
<description>
The result of dot(Dwave, (0,1)), i.e. the sine of the angle
between the wave heading and the hull heading.
</description>
<function>
<sin>
<property>hydro/environment/wave/relative-heading-rad</property>
</sin>
</function>
</fcs_function>
<fcs_function name="hydro/environment/wave/hull-angular-frequency-rad_sec">
<description>
Hull speed in the wave's direction expressed in the wave's
angular frequency.
</description>
<function>
<product>
<value>6.2831853</value>
<quotient>
<sum>
<product>
<property>hydro/vbx-fps</property>
<property>hydro/environment/wave/hull-x-factor</property>
</product>
<product>
<property>hydro/vby-fps</property>
<property>hydro/environment/wave/hull-y-factor</property>
</product>
</sum>
<max>
<value>0.001</value>
<property>hydro/environment/wave-length-ft</property>
</max>
</quotient>
</product>
</function>
</fcs_function>
<integrator name="hydro/environment/wave/hull-angular-offset-rad">
<description>
The hull's angular offset at its present position.
</description>
<input>hydro/environment/wave/hull-angular-frequency-rad_sec</input>
<c1>1.0</c1>
</integrator>
<fcs_function name="hydro/environment/wave/angular-frequency-rad_sec">
<description>
The angular frequency of the wave.
</description>
<function>
<sum>
<!-- Deep water gravity wave. -->
<product>
<value>-1.0</value> <!-- Note: Set to 0 to make the waves stationary. -->
<pow>
<quotient>
<product>
<value>6.2831853</value>
<property>hydro/environment/gravity-ft_sec2</property>
</product>
<max>
<value>0.001</value>
<property>hydro/environment/wave-length-ft</property>
</max>
</quotient>
<value>0.5</value>
</pow>
</product>
<!-- Mix in hull-angular-offset-rad to simplify uses below. -->
<quotient>
<property>hydro/environment/wave/hull-angular-offset-rad</property>
<max> <!-- To avoid divison by 0 at time 0. -->
<value>0.1</value>
<property>simulation/sim-time-sec</property>
</max>
</quotient>
</sum>
</function>
</fcs_function>
<fcs_function name="hydro/environment/wave/wave-number-rad_ft">
<description>
The wave number of the wave.
</description>
<function>
<quotient>
<value>6.2831853</value>
<max>
<value>0.001</value>
<property>hydro/environment/wave-length-ft</property>
</max>
</quotient>
</function>
</fcs_function>
<fcs_function name="hydro/environment/wave/level-change-ft">
<description>
The water level change due to the waves. Guessed.
Integrated over -0.5 * hydro-length-ft to 0.5 * hydro-length-ft.
</description>
<function>
<quotient>
<sum>
<product>
<property>hydro/environment/wave-amplitude-ft</property>
<sin>
<difference>
<product>
<value>0.5</value>
<property>metrics/hydro-length-ft</property>
<property>hydro/environment/wave/hull-x-factor</property>
<property>hydro/environment/wave/wave-number-rad_ft</property>
</product>
<product>
<property>hydro/environment/wave/angular-frequency-rad_sec</property>
<property>simulation/sim-time-sec</property>
</product>
</difference>
</sin>
</product>
<product>
<property>hydro/environment/wave-amplitude-ft</property>
<sin>
<difference>
<product>
<value>-0.5</value>
<property>metrics/hydro-length-ft</property>
<property>hydro/environment/wave/hull-x-factor</property>
<property>hydro/environment/wave/wave-number-rad_ft</property>
</product>
<product>
<property>hydro/environment/wave/angular-frequency-rad_sec</property>
<property>simulation/sim-time-sec</property>
</product>
</difference>
</sin>
</product>
</sum>
<product>
<property>hydro/environment/wave/hull-x-factor</property>
<property>hydro/environment/wave/wave-number-rad_ft</property>
<property>hydro/hull-length-ft</property>
</product>
</quotient>
</function>
</fcs_function>
<fcs_function name="hydro/environment/wave/level-at-hrp-ft">
<description>
The water level change at the HRP location. For debugging.
</description>
<function>
<product>
<property>hydro/environment/wave-amplitude-ft</property>
<cos>
<product>
<property>hydro/environment/wave/angular-frequency-rad_sec</property>
<property>simulation/sim-time-sec</property>
</product>
</cos>
</product>
</function>
</fcs_function>
<fcs_function name="hydro/environment/wave/level-fwd-ft">
<description>
The water level change at 0.5 * metrics/hydro-length-ft forward of
the HRP location.
</description>
<function>
<product>
<property>hydro/environment/wave-amplitude-ft</property>
<cos>
<difference>
<product>
<value>0.5</value>
<property>metrics/hydro-length-ft</property>
<property>hydro/environment/wave/hull-x-factor</property>
<property>hydro/environment/wave/wave-number-rad_ft</property>
</product>
<product>
<property>hydro/environment/wave/angular-frequency-rad_sec</property>
<property>simulation/sim-time-sec</property>
</product>
</difference>
</cos>
</product>
</function>
</fcs_function>
<fcs_function name="hydro/environment/wave/level-aft-ft">
<description>
The water level change at 0.5 * metrics/hydro-length-ft aft of
the HRP location.
</description>
<function>
<product>
<property>hydro/environment/wave-amplitude-ft</property>
<cos>
<difference>
<product>
<value>-0.5</value>
<property>metrics/hydro-length-ft</property>
<property>hydro/environment/wave/hull-x-factor</property>
<property>hydro/environment/wave/wave-number-rad_ft</property>
</product>
<product>
<property>hydro/environment/wave/angular-frequency-rad_sec</property>
<property>simulation/sim-time-sec</property>
</product>
</difference>
</cos>
</product>
</function>
</fcs_function>
<fcs_function name="hydro/orientation/wave-pitch-trim-change-deg">
<description>
The pitch trim change due to the waves. Guessed.
</description>
<!-- deltaTrim = atan2(water line at bow - water line at stern, LWL) -->
<function>
<product>
<value>57.29578</value>
<atan2>
<difference>
<property>hydro/environment/wave/level-fwd-ft</property>
<property>hydro/environment/wave/level-aft-ft</property>
</difference>
<property>metrics/hydro-length-ft</property>
</atan2>
</product>
</function>
</fcs_function>
<fcs_function name="hydro/orientation/wave-roll-trim-change-deg">
<description>
The roll trim change due to the waves. Guessed.
</description>
<!-- deltaTrim =
atan2(water line at starboard side - water line at port side, beam)
-->
<function>
<product>
<value>57.29578</value>
<atan2>
<difference>
<product>
<property>hydro/environment/wave-amplitude-ft</property>
<cos>
<difference>
<product>
<value>-0.5</value>
<property>metrics/hydro-beam-ft</property>
<property>hydro/environment/wave/hull-y-factor</property>
<property>hydro/environment/wave/wave-number-rad_ft</property>
</product>
<product>
<property>hydro/environment/wave/angular-frequency-rad_sec</property>
<property>simulation/sim-time-sec</property>
</product>
</difference>
</cos>
</product>
<product>
<property>hydro/environment/wave-amplitude-ft</property>
<cos>
<difference>
<product>
<value>0.5</value>
<property>metrics/hydro-beam-ft</property>
<property>hydro/environment/wave/hull-y-factor</property>
<property>hydro/environment/wave/wave-number-rad_ft</property>
</product>
<product>
<property>hydro/environment/wave/angular-frequency-rad_sec</property>
<property>simulation/sim-time-sec</property>
</product>
</difference>
</cos>
</product>
</difference>
<property>metrics/hydro-beam-ft</property>
</atan2>
</product>
</function>
</fcs_function>
</channel>
<channel name ="Hull position">
<fcs_function name="hydro/height-agl-ft">
<documentation>
Distance between the hydrodynamic reference point and the water surface.
Not completely correctly computed yet.
</documentation>
<function>
<difference>
<sum>
<property> position/h-sl-ft </property>
<product>
<value> -0.083333333 </value>
<difference>
<property> metrics/hydro-rp-x-in </property>
<property> inertia/cg-x-in </property>
</difference>
<sin>
<property> attitude/pitch-rad </property>
</sin>
</product>
<product>
<value> 0.083333333 </value>
<difference>
<property> metrics/hydro-rp-z-in </property>
<property> inertia/cg-z-in </property>
</difference>
<cos>
<property> attitude/pitch-rad </property>
</cos>
</product>
<product>
<value> -0.083333333 </value>
<difference>
<property> metrics/hydro-rp-y-in </property>
<property> inertia/cg-y-in </property>
</difference>
<sin>
<property> attitude/roll-rad </property>
</sin>
</product>
</sum>
<property> hydro/environment/water-level-ft </property>
</difference>
</function>
</fcs_function>
</channel>
<channel name ="Hull orientation">
<fcs_function name="hydro/true-course-rad">
<!-- The course made good by the hull. -->
<function>
<atan2>
<sum>
<property>velocities/v-east-fps</property>
<property>hydro/environment/current-from-east-fps</property>
</sum>
<sum>
<property>velocities/v-north-fps</property>
<property>hydro/environment/current-from-north-fps</property>
</sum>
</atan2>
</function>
</fcs_function>
<fcs_function name="hydro/true-course-deg">
<!-- The course made good by the hull. -->
<function>
<product>
<value> 57.29578 </value>
<property> hydro/true-course-rad </property>
</product>
</function>
</fcs_function>
<fcs_function name="hydro/pitch-deg">
<function>
<product>
<value> 57.29578 </value>
<property> attitude/pitch-rad </property>
</product>
</function>
</fcs_function>
<fcs_function name="hydro/roll-deg">
<function>
<product>
<value> 57.29578 </value>
<property> attitude/roll-rad </property>
</product>
</function>
</fcs_function>
<fcs_function name="hydro/alpha-rad">
<function>
<sum>
<property>attitude/pitch-rad</property>
<atan2>
<property>velocities/v-down-fps</property>
<property>hydro/v-fps</property>
</atan2>
</sum>
</function>
</fcs_function>
<fcs_function name="hydro/alpha-deg">
<function>
<product>
<value> 57.29578 </value>
<property> hydro/alpha-rad </property>
</product>
</function>
</fcs_function>
<fcs_function name="hydro/tmp/beta-rad">
<!-- Needed to normalize the beta range to +/-PI. -->
<function>
<difference>
<property> hydro/true-course-rad </property>
<property> attitude/psi-rad </property>
</difference>
</function>
</fcs_function>
<fcs_function name="hydro/beta-rad">
<function>
<sum>
<property>hydro/tmp/beta-rad</property>
<product>
<lt>
<property>hydro/tmp/beta-rad</property>
<value>-3.1415927</value>
</lt>
<value>6.2831853</value>
</product>
<product>
<gt>
<property>hydro/tmp/beta-rad</property>
<value>3.1415927</value>
</gt>
<value>-6.2831853</value>
</product>
</sum>
</function>
</fcs_function>
<fcs_function name="hydro/beta-deg">
<function>
<product>
<value> 57.29578 </value>
<property> hydro/beta-rad </property>
</product>
</function>
</fcs_function>
</channel>
<channel name ="Hull velocity">
<fcs_function name="hydro/v-fps">
<function>
<pow>
<sum>
<pow>
<sum>
<property> velocities/v-north-fps </property>
<property> hydro/environment/current-from-north-fps </property>
</sum>
<value> 2.0 </value>
</pow>
<pow>
<sum>
<property> velocities/v-east-fps </property>
<property> hydro/environment/current-from-east-fps </property>
</sum>
<value> 2.0 </value>
</pow>
</sum>
<value> 0.5 </value>
</pow>
</function>
</fcs_function>
<fcs_function name="hydro/v-kt">
<function>
<product>
<value> 0.5924838 </value>
<property> hydro/v-fps </property>
</product>
</function>
</fcs_function>
<fcs_function name="hydro/vbx-fps">
<function>
<product>
<cos>
<property>hydro/beta-rad</property>
</cos>
<property>hydro/v-fps</property>
</product>
</function>
</fcs_function>
<fcs_function name="hydro/vby-fps">
<function>
<product>
<sin>
<property>hydro/beta-rad</property>
</sin>
<property>hydro/v-fps</property>
</product>
</function>
</fcs_function>
<fcs_function name="hydro/qbar-psf">
<function>
<product>
<value> 0.50 </value>
<property>hydro/environment/rho-slug_ft3</property>
<property>hydro/v-fps</property>
<property>hydro/v-fps</property>
</product>
</function>
</fcs_function>
<fcs_function name="hydro/qbar-u-psf">
<function>
<product>
<value> 0.50 </value>
<property>hydro/environment/rho-slug_ft3</property>
<property>hydro/vbx-fps</property>
<abs><property>hydro/vbx-fps</property></abs>
</product>
</function>
</fcs_function>
<fcs_function name="hydro/qbar-v-psf">
<function>
<product>
<value> 0.50 </value>
<property>hydro/environment/rho-slug_ft3</property>
<property>hydro/vby-fps</property>
<abs><property>hydro/vby-fps</property></abs>
</product>
</function>
</fcs_function>
</channel>
<!-- Implementation of forces and moments below. -->
<channel name="Implementation Force X (north)">
<fcs_function name="hydro/X/force-lbs">
<function>
<sum>
<product>
<cos>
<property> attitude/psi-rad </property>
</cos>
<property> hydro/fbx-lbs </property>
</product>
<product>
<sin>
<property> attitude/psi-rad </property>
</sin>
<property> hydro/fby-lbs </property>
</product>
<product>
<value> -1.0 </value>
<cos>
<property> hydro/true-course-rad </property>
</cos>
<property> hydro/fdrag-lbs </property>
</product>
<product>
<value> -1.0 </value>
<sin>
<property> hydro/true-course-rad </property>
</sin>
<property> hydro/fside-lbs </property>
</product>
</sum>
</function>
<output> external_reactions/hydro-X/magnitude </output>
</fcs_function>
</channel>
<channel name="Implementation Force Y (east)">
<fcs_function name="hydro/Y/force-lbs">
<function>
<sum>
<product>
<sin>
<property> attitude/psi-rad </property>
</sin>
<property> hydro/fbx-lbs </property>
</product>
<product>
<cos>
<property> attitude/psi-rad </property>
</cos>
<property> hydro/fby-lbs </property>
</product>
<product>
<value> -1.0 </value>
<sin>
<property> hydro/true-course-rad </property>
</sin>
<property> hydro/fdrag-lbs </property>
</product>
<product>
<cos>
<property> hydro/true-course-rad </property>
</cos>
<property> hydro/fside-lbs </property>
</product>
</sum>
</function>
<output> external_reactions/hydro-Y/magnitude </output>
</fcs_function>
</channel>
<channel name="Implementation Force Z (up)">
<summer name="hydro/Z/force-lbs">
<input> hydro/fbz-lbs </input>
<output> external_reactions/hydro-Z/magnitude </output>
</summer>
</channel>
<channel name="Implementation Pitch Moment">
<pure_gain name="hydro/pitch-moment/force-lbs[0]">
<input> hydro/pitch-moment-lbsft </input>
<gain> 0.5</gain>
<output> external_reactions/hydro-pitch[0]/magnitude </output>
</pure_gain>
<pure_gain name="hydro/pitch-moment/force-lbs[1]">
<input> hydro/pitch-moment-lbsft </input>
<gain>-0.5</gain>
<output> external_reactions/hydro-pitch[1]/magnitude </output>
</pure_gain>
</channel>
<channel name="Implementation Roll Moment">
<pure_gain name="hydro/roll-moment/force-lbs[0]">
<input> hydro/roll-moment-lbsft </input>
<gain> 0.5</gain>
<output> external_reactions/hydro-roll[0]/magnitude </output>
</pure_gain>
<pure_gain name="hydro/roll-moment/force-lbs[1]">
<input> hydro/roll-moment-lbsft </input>
<gain>-0.5</gain>
<output> external_reactions/hydro-roll[1]/magnitude </output>
</pure_gain>
</channel>
<channel name="Implementation Yaw Moment">
<pure_gain name="hydro/yaw-moment/force-lbs[0]">
<input> hydro/yaw-moment-lbsft </input>
<gain> 0.5</gain>
<output> external_reactions/hydro-yaw[0]/magnitude </output>
</pure_gain>
<pure_gain name="hydro/yaw-moment/force-lbs[1]">
<input> hydro/yaw-moment-lbsft </input>
<gain>-0.5</gain>
<output> external_reactions/hydro-yaw[1]/magnitude </output>
</pure_gain>
</channel>
</system>