3D Model of Fuel Tank for System Simulation
 A methodology for combining CAD models with simulation tools 
Jonas Wikström
Division of Machine Design
Master Thesis
Department of Management and Engineering
LIUIEITEKA11/01201SE
Linköping 2011
Supervisor at Linköping University: Mehdi Tarkian
Supervisor at SAAB Aeronautics: Ingela Lind
Abstract
Engineering aircraft systems is a complex task. Therefore models and computer
simulations are needed to test functions and behaviors of non existing systems, reduce
testing time and cost, reduce the risk involved and to detect problems early which reduce
the amount of implementation errors. At the section Vehicle Simulation and Thermal
Analysis at Saab Aeronautics in Linköping every basic aircraft system is designed and
simulated, for example the fuel system. Currently 2dimensional rectangular blocks are
used in the simulation model to represent the fuel tanks. However, this is too simplistic to
allow a more detailed analysis. The model needs to be extended with a more complex
description of the tank geometry in order to get a more accurate model.
This report explains the different steps in the developed methodology for combining 3
dimensional geometry models of any fuel tank created in CATIA with dynamic
simulation of the fuel system in Dymola. The new 3dimensional representation of the
tank in Dymola should be able to calculate fuel surface location during simulation of a
maneuvering aircraft.
The first step of the methodology is to create a solid model of the fuel contents in the
tank. Then the area of validity for the model has to be specified, in this step all possible
orientations of the fuel acceleration vector within the area of validity is generated. All
these orientations are used in the automated volume analysis in CATIA. For each
orientation CATIA splits the fuel body in a specified number of volumes and records the
volume, the location of the fuel surface and the location of the center of gravity. This
recorded data is then approximated with the use of radial basis functions implemented in
MATLAB. In MATLAB a surrogate model is created which are then implemented in
Dymola. In this way any fuel surface location and center of gravity can be calculated in
an efficient way based on the orientation of the fuel acceleration vector and the amount of
fuel.
The new 3dimensional tank model is simulated in Dymola and the results are compared
with measures from the model in CATIA and with the results from the simulation of the
old 2dimensional tank model. The results shows that the 3dimensional tank gives a
better approximation of reality and that there is a big improvement compared with the 2
dimensional tank model. The downside is that it takes approximately 24 hours to develop
this model.
Sammanfattning
Att utveckla ett nytt flygplanssystem är en väldigt komplicerad arbetsuppgift. Därför
används modeller och simuleringar för att testa icke befintliga system, minska
utvecklingstiden och kostnaderna, begränsa riskerna samt upptäcka problem tidigt och på
så sätt minska andelen implementerade fel. Vid sektionen Vehicle Simulation and
Thermal Analysis på Saab Aeronautics i Linköping designas och simuleras varje
grundflygplanssystem, ett av dessa system är bränslesystemet. För närvarande används 2
dimensionella rätblock i simuleringsmodellen för att representera bränsletankarna, vilket
är en väldigt grov approximation. För att kunna utföra mer detaljerade analyser behöver
modellerna utökas med en bättre geometrisk beskrivning av bränsletankarna.
Denna rapport går igenom de olika stegen i den framtagna metodiken för att kombinera
3 dimensionella tankmodeller skapade i CATIA med dynamisk simulering av
bränslesystemet i Dymola. Den nya 3dimensionella representationen av en tank i
Dymola bör kunna beräkna bränsleytans läge under en simulering av ett manövrerande
flygplan.
Första steget i metodiken är att skapa en solid modell av bränslet som finns i tanken.
Därefter specificeras modellens giltighetsområde och alla tänkbara riktningar hos
accelerationsvektorn som påverkar bränslet genereras, dessa används sedan i den
automatiserade volymanalysen i CATIA. För varje riktning delar CATIA upp
bränslemodellen i ett bestämt antal delar och registrerar volymen, bränsleytans läge samt
tyngdpunktens position för varje del. Med hjälp av radiala basfunktioner som har
implementerats i MATLAB approximeras dessa data och en surrogatmodell tas fram,
denna implementeras sedan i Dymola. På så sätt kan bränsleytans och tyngdpunktens läge
beräknas på ett effektivt sätt, baserat på riktningen hos bränslets accelerationsvektor samt
mängden bränsle i tanken.
Den nya 3dimensionella tankmodellen simuleras i Dymola och resultaten jämförs med
mätningar utförda i CATIA samt med resultaten från den gamla simuleringsmodellen.
Resultaten visar att den 3dimensionella tankmodellen ger en mycket bättre
representation av verkligheten och att det är en stor förbättring jämfört med den 2
dimensionella representationen. Nackdelen är att det tar ungefär 24 timmar att få fram
denna 3dimensionella representation.
Acknowledgment
First of all I would like to thank my supervisor at Saab, Ingela Lind for her commitment
and interest. She has guided and helped me to succeed with the objectives of this master
thesis. I would also like to thank Mehdi Tarkian, supervisor at Linköping University for
all the tips and all the guidance regarding the approach, CATIA and thesis writing in
general.
Also a thanks to Anders Darander consultant from ChargeStorm, Peter Berntsson CAD
support at Saab, Erik Ocholla fellow student and student reviewer and all the rest that has
contributed in one way or another.
Table of Contents
1 INTRODUCTION  7
1.1 BACKGROUND  7
1.1.1 Why simulate  8
1.1.2 The tank model today  10
1.2 PROBLEM DEFINITION  11
1.3 PURPOSE  12
1.4 OBJECTIVES  12
1.5 LIMITATIONS  12
1.6 DISPOSITION  13
2 APPROACH  15
2.1 DEVELOPMENT PROCESS  15
2.1.1 System Engineering  15
2.1.2 Divergent problem solving  16
2.2 INVOLVED DISCIPLINES AND USED TOOLS  17
2.2.1 Computer Aided Design (CAD) with CATIA  17
2.2.2 Data driven function approximation in MATLAB  18
Radial Basis Functions  19
2.2.3 Dynamic simulation in Dymola  20
3 PROPOSED METHODOLOGY  21
3.1 DEVELOP A 3D MODEL OF THE FUEL  21
3.2 DEFINE THE AREA OF VALIDITY  22
3.3 VOLUME ANALYSIS IN CATIA  23
3.4 DEVELOP A SURROGATE MODEL  28
3.5 IMPLEMENT THE MODEL IN DYMOLA  29
3.6 VERIFY PORT POSITIONS  31
4 RESULTS  33
4.1 DATA PROCESSING  33
4.1.1 CATIA  33
4.1.2 MATLAB  33
4.2 RESOLUTION OF THE DATA  34
4.3 MODEL SIMULATION IN DYMOLA  35
4.3.1 Test system  35
4.3.2 Performance  36
4.4 VALIDATION AGAINST MEASURED DATA  36
4.5 SUPPORTED TANK GEOMETRIES  38
5 CONCLUSIONS  39
5.1 DISCUSSION AND CONCLUSIONS  39
REFERENCES  43
APPENDIX  45
APPENDIX 1. ORIENTATION OF FUEL ACC. (MATLAB FUNCTION)  45
APPENDIX 2. HOW TO ACCESS SCRIPTS IN CATIA  46
APPENDIX 3. COPY THE SOLID INTO A NEW PART (CATIA SCRIPT)  47
APPENDIX 4. PREPARE THE MODEL (CATIA SCRIPT)  49
APPENDIX 5. HOW TO INSERT MEASURES IN CATIA  52
APPENDIX 6. PREPARE THE ANALYSIS (CATIA SCRIPT)  55
APPENDIX 7. RUN THE ANALYSIS (CATIA SCRIPT)  58
APPENDIX 8. RBF (MATLAB FUNCTION)  66
APPENDIX 9. RBF_CALC (MATLAB FUNCTION)  68
APPENDIX 10. DIVIDE_DATA (MATLAB FUNCTION)  69
APPENDIX 11. TRAIN_RBF (MATLAB FUNCTION)  70
APPENDIX 12. SIM_RBF (MATLAB FUNCTION)  72
APPENDIX 13. CHECK PORTS (CATIA SCRIPT)  73
APPENDIX 14. MAX VOLUME ERROR (MATLAB FUNCTION)  76
7
1 Introduction
This chapter aims to give an introduction to why a 3 dimensional fuel tank model is
needed and why computer simulations are used. The purpose and the objectives of this
master’s thesis are outlined and the chapter finishes off by giving an overview of the
remaining chapters.
1.1 Background
According to Gavel (2007) the complete fuel system of the combat aircraft Saab 39
Gripen was simulated in a fullscale test rig during the initial development, mostly due to
lack of computer power. When the Gripen was upgraded a major modification was made
to the fuel system. At that point computer power was not an issue and the test rig alone
would have become a bottleneck in the development. A decision to build a mathematical
model of the system was taken. It took over 5000 hours to develop and involved seven
simulation and system engineers.
Lind (2011) explains that engineering aircraft systems is a complex task due to a lot of
factors; expensive equipment, expensive tests, long lead times, safety constraints and
varying environmental conditions. A high interaction between systems and different
engineering disciplines are needed.
Gavel (2007) states that the fuel system is the largest fluid system in the aircraft and
consists mostly of several tanks. This can be seen in figure 1. The size, shape and
placement of the fuel tanks do not only determine how far the aircraft can fly but also the
stability and safety of the aircraft. In order to operate the aircraft the center of gravity
must sit within a limited space and the fuel is a big contributor to the aircrafts center of
gravity. According to Langton et al. (2009) one of the biggest challenges of fuel system
design is to cope with the complex geometries of the fuel tanks. In order to get a better
understanding, tank models are needed to compute fuel surface location for various fuel
quantities, aircraft attitudes and acceleration forces.
Figure 1 The tank layout of Saab 39 Gripen
8
At the section Vehicle Systems Simulation and Thermal Analysis at Saab Aeronautics in
Linköping every basic aircraft system, which includes hydraulic , fuel , power , power
support , landing gear , rescue  and environmental control systems is designed and
tested in computer simulations. Most of the simulations are done in Dymola using
Modelica, which is an object oriented modeling language for modeling complex physical
systems.
Johannesson et al. (2004) writes that many tools used for advance modeling, analysis and
simulation are designed for one specific purpose. During a development process all these
tools are often used to some extent and it is of interests to have an interaction between
them. That is why researchers today focus on finding interfaces between the different
tools so that they can be more useful and used together during the whole development
process.
Ullman (2003) explains that it is vital to the success of a project that the right design
decisions are made during the early stages in the development process. A lot of money
and time can be saved if a problem can be discovered and corrected as soon as in the
planning phase.
1.1.1 Why simulate
Johannesson et al. (2004) states that products today are more complex and consists of
many different systems such as mechanical, power electric, sensors, central processor
units (CPU) and control systems. This leads to one of the challenges of today‟s product
development, which is to manage complexity of multi technological products. According
to Langton et al. (2009), modeling is necessary to provide valuable insight into the
behavior of the highly nonlinear aspects of fuel systems and their functions.
Adam Thorp addressed during the ModProd conference in Linköping 2011 that the
enhanced products and the wish to reduce cost has made a need for system simulation.
At the same conference another important issue was raised by Dr. Xialong Feng, that the
most important issue in product development is the time to market, which according to
Ullman (2003) means that you need to do right from beginning. According to
Johannesson et al. (2004), laboratory tests and physical prototypes is often time
consuming and expensive. By running a simulation on a computer the time and cost can
be cut and the function and behavior of a system or product can still be predicted. This
knowledge of the possible outcome is extremely valuable for companies as it allows an
assessment of the risk involved.
A system is defined by Ljung and Glad (2004) as one or more objects whose behavior are
to be investigated. One way of doing this is to do experiments, but this is not always
possible. A common cause is that the system does not yet exist. Then a model of the
system can be used. A model is a simplified representation of a real system. According to
Johannesson et al. (2004), a simulation model is used for testing different parameter
setups and components and their effect on the system. Through fast iteration loops many
different setups can be tested. One advantage is by Brooks and Robinsons (2001) that
each iteration can be repeated under the same conditions.
9
Brooks and Robinson (2001) also claim that simulations can be used for modeling
dangerous situations, for example what happens if the fuel pump in the aircraft stops
working? Simulations also provide a safe environment for training, where mistakes can
be made without any serious consequences.
Brooks and Robinson (2001) also state that because of simplifications, the model is not to
be trusted completely. The result needs to be verified through real tests, were load cases
and configurations can be based on the results from the simulation. Based on the results
from the real tests the model can be updated to better match reality. Ljung and Glad
(2004) stress the importance of model validation and the knowledge of the area of
validity, the area in which the model works.
According to Lind (2011) the ambition of using model based system engineering at Saab
has various reasons. For example; to detect problems early, increase the ability to
optimize design for different purposes, reduce the amount of implementation errors,
reduce project risk, gain better control of model variants, get more effective system
engineering, reduce testing time and cost, effectively use data from tests and also to get
better secondary products, such as training simulators.
These ambitions reflect very well with what the research community has mentioned as
reasons for model based design.
10
1.1.2 The tank model today
The tank model is built in Dymola using the Modelica language. It consists of different
components that are linked together by relations and constrains. The basic function of the
tank model is to calculate air pressure and hydrostatic pressure at connection points,
based on air and fuel flow. This calculation also depends on the aircraft‟s attitude (the
orientation of an aircraft‟s axes relative to a reference, such as the horizon) and the size
and orientation of the acceleration vector.
Like in most models some assumptions are made. Some of them are that the tank is
rectangular in three dimensions and liquid level can vary in two dimensions and remains
parallel to the third. The tank has ideal phase separation between liquid fuel and gas at
any time and the fluid consists of liquid fuel, fuel vapor and air. Fluid temperature is
uniform and heat capacitance for the tank walls is not included, but can be dealt with
separately. The gas pressure is also uniform and the pressure at the ports is total pressure
that depends on the overall thermodynamic state in the volume and on the static head of
liquid above the port. Kinetic and potential energy terms are neglected in energy balance
and the fluid velocity inside the tank in ignored. The fuel level is assumed to be
perpendicular to the acceleration vector without any time lag.
The tanks are designed so that the total volume, the unused fuel and the position of intake
ports are as close to reality as possible. This means that the dimensions and the position
of the tank and the ports are roughly approximated to give as good results as possible for
the most common attitudes and accelerations. Because the fuel level varies in a 2
dimensional plane, it has to be specified in which plane, xy or xz the calculations will be
performed in and which components of the acceleration vector that will be used.
Dynamic terms, fluid and port properties are defined and initial values for liquid fuel
mass, gas pressure, temperature and gas phase composition are set.
Before any simulation can be performed there is a test that verifies that the ports and test
probes are placed within the tank. When the ports positions are confirmed the function
fuel level is initialized. This function calculates the distance from the fuel surface down to
the different ports. Based on the amount of fuel an area in the 2dimensional plane is
created and by using symmetry and given angles, the distance between surface and ports
can be derived. The function then returns this information back to the model which
calculates pressure, enthalpy and mass flow and updates the mass and energy balances in
the fuel system. The total pressures at the tank ports are crucial in order to describe the
hydraulic behavior of the fuel system. Figure 2 shows an illustration of the tank model
and how the fuel is oriented by the acceleration vector. During the simulation it is
possible to get an animation of how the fuel level varies in the tank.
11
Figure 2 The tank model with the orientation of the acceleration g and the distance d from fuel
surface to a port.
1.2 Problem definition
Representing fuel tanks with rectangular blocks is too simplistic to allow more detailed
analysis. The tank model has to be extended with a more detailed description of the tank
geometry in order to be able to get a more accurate simulation model. The fuel tanks
contain several sensors for fuel level and a lot of intakes and venting ports. Because of
aircraft maneuvering and gloads, the fuel moves around in the tank. This needs to be
predicted by a mathematical model so that a sensor output is not interpreted as “out of
fuel” just because the fuel has moved to another part of the tank. Likewise the sensors
must indicate when the aircraft is 100% refueled to prevent overfilling. It is also of
interest to know if all the inlets to the pipes that are supposed to transport the fuel are
covered with fuel and what the hydrostatic pressure is at the inlet. It is very important that
the engine is not fed by air as that can cause a flameout (failure to the jet engine).
A 3dimensional representation of the actual tank would help answering these questions
as it would give a better insight into where the fuel is located.
There are available 3dimensional models of the fuel tanks made in CATIA V5. The
problem is how to use the information from these models for calculating the fuel level
during dynamic simulation of a maneuvering aircraft in an efficient and correct way, so
that it can be used for dynamic simulation for system design and in realtime simulators.
12
1.3 Purpose
The purpose of this master thesis is to investigate and develop a methodology for using
geometry data of any fuel tank from a 3dimensional CATIA model in a dynamic
simulation in Dymola. The method should support a fast, correct and repeatable
procedure so that the simulation becomes efficient.
1.4 Objectives
The objectives of this methodology for combining 3D modeling of fuel tanks and
dynamic simulation of the fuel system are as follows:
 To compute fuel surface location for various fuel quantities, aircraft attitudes and
acceleration forces and also the center of gravity for the fuel. The calculated result
should have a tolerance of around 10 liters.
 Develop a 3dimensional tank model in Dymola that can calculate the hydrostatic
pressure at an inlet during simulation of a maneuvering aircraft, generate realtime
code and fit into the existing library.
 To construct an easy test that verifies that intakes, venting ports and test probes
are placed within the tank geometry.
 To make a technology demonstrator, that shows how CATIA and Dymola from
Dassault Systèmes can support system development.
1.5 Limitations
The tools used for developing this methodology are restricted to the tools used at Saab.
Given that Saab has a close cooperation with Dassault Systèmes it is favorable to do as
much as possible in their programs, CATIA and Dymola. Due to previous experiences,
MATLAB will be used for the development of a surrogate model. There are also
readymade applications for function approximation to be found on the internet for
MATLAB. These applications are a good start and can be rewritten to serve the purpose
of this master thesis.
It is desirable to make the end result as close to reality as possibly but as in most models
some simplifications must be made.
According to Diston et al. the position of fuel inside a tank, for a given fuel state, is
determined by aircraft orientation, acceleration and aero elastic deflection. The aero
elastic deflection is the structural deformation caused by aerodynamic force, the force
exerted by the air. The aero elastic deflection will be neglected in this master thesis
because of its small impact and the extra work needed to simulate it.
Diston et al. also states that the fuel surface can be seen as a ripple free surface bounded
by the tank walls and normal to the fuel acceleration vector. This is an acceptable
simplification under normal operating conditions but will clearly break down under any
maneuvering when the fuel sloshes.
13
During this work the fuel level is assumed to be perpendicular to the fuel acceleration
vector without any time lag. It is also assumed that the fuel is evenly distributed at all
time. This is a reasonable assumption, since there are always pipes connecting the
different compartments of the tank. In other types of geometry, fuel slosh takes care of
giving equal levels. This is shown in figure 3.
Figure 3 The assumed distribution of fuel
When the aircraft is being refueled, air is sometimes trapped in air pockets. These pockets
will not be dealt with during this master thesis. It is assumed that no air pockets exist.
1.6 Disposition
Chapter 2 presents some useful models which the development process has been based
on. It also introduces the tools and what they are used for.
Chapter 3 explains all the steps of this thesis work, from 3D modeling in CATIA to
dynamic simulation in Dymola.
Chapter 4 presents the results from each step in aspects of both time requirements and
accuracy. The created 3dimensional tank model is simulated and the result is compared
against the old tank model.
Chapter 5 contains discussion and conclusions. Different aspects of the work are
analyzed and potential improvements are presented.
14
15
2 Approach
The development process has been based on some useful models which are presented.
There is also some introduction to the tools used in this master thesis and what they are
used for.
2.1 Development process
When developing a new product it is good to have some structured method to follow.
During this work the development process has been influenced by the system engineering
model and most problems encountered have been solved with iterative divergent problem
solving.
2.1.1 System Engineering
According to Johannesson et al. (2004) the philosophy of system engineering is used for
developing complex system solutions. The process can be described by the so called V
model which can be seen in figure 4.
Figure 4 The Vmodel for system engineering
The first step is to identify all the requirements. These needs should be expressed in the
users terminology and be as functional as possible. This has been achieved through
contact with the employees at the section Vehicle Systems Simulation and Thermal
Analysis at Saab Aeronautics in Linköping and thorough the master thesis proposal. In
the system criteria step the collected needs are translated into criteria‟s which the system
must fulfill, a product specification is constructed. In this master thesis these product
specifications are listed as objectives in the introduction. The next step is to develop the
system architecture, to construct concepts and evaluate them. In this case a concept
means a solution on how to use geometry data of any fuel tank from a 3dimensional
CATIA model in a dynamic simulation in Dymola. In order to simplify the process of
concept development, the concepts have been designed so that they are easy to upgrade,
can be used in other contexts and already developed solutions have been put together to
serve the purpose of this master thesis, for example the use of radial basis functions
(RBF) for surrogate modeling and parts of the CATIA scripts.
16
When the system architecture is done there should be a system solution that fulfills the
criteria‟s with available resources. The different sub solutions and the interaction between
the system components should be identified both with respect to technology and which
way to implement them. The system solution for this master thesis consists of extracting
necessary information from the CATIA model. This information is then used to create a
surrogate model in MATLAB which can be implemented and simulated in Dymola. It is
in this step all compromises and testing strategies are supposed to be identified, but
during this master thesis, this was something that evolved during the work. In the last
step of the development the designed system is split into smaller components which are
described in detail and designed. This means that the data extraction from CATIA is split
into a couple of steps, in this case into different scripts and the surrogate modeling is split
into different MATLAB functions.
The right side of the Vmodel is all about verification and validation. During component
testing each CATIA script and MATLAB function is tested individually to make sure it
works as planned. In the next step all CATIA scripts are executed in the planed sequence
and the results from CATIA are used in MATLAB to create a surrogate model which is
implemented and simulated in Dymola. In this step errors in the interfaces and in the
interaction between the modules can be detected. In system testing the developed tank
model is simulated and the results are compared with the specifications to see if it meets
the requirements. The last test is the user acceptance test. The proposed methodology will
be tested and evaluated by the users at Saab to see if the solution satisfies the user needs.
2.1.2 Divergent problem solving
According to Johannesson et al. (2004) the process of product development can be seen
as a structured problem solving where there is not just one right answer to the problem.
In this master thesis the design and verification of components (different CATIA scripts
and MATLAB functions) and their interaction with each other can be seen as such a
structured problem solving. In order to develop the best possible component, which will
work together with the other components and meet the requirements of the system (the
objectives), the model of an iterative problem solving process is used. The process is
explained in figure 5.
Figure 5 Process for iterative problem solving
It starts with a problem analysis where as much background information as possible is
gathered and the problem is formulated. The problem analysis should result in a
requirement specification of what the product should be able to perform.
17
These demands will change during the process as new sub problems and solutions arise
and more knowledge about the product is gained. The next step is to generate solution
concepts with a divergent approach. A lot of solutions can be generated as there are many
ways to solve a problem. All found solutions have to be analyzed regarding properties
and performance. During this phase a sensitivity analysis can also be conducted, in which
different parameter setups and their effect on the system are investigated. The different
solutions are then being compared against each other and the specifications. If the
demands are not fulfilled the concept development starts all over and the concepts are
being modified or new ones are developed, with the sensitivity analysis in mind. The
concepts are being analyzed once more and this repeats itself until all demands are met.
Sometimes it is not possible to meet all the demands, then the problem has to be revised
and the specifications have to be modified. When an acceptable solution has been found
the process is completed but there is always the possibility to optimize further.
2.2 Involved disciplines and used tools
The process of transforming a 3 dimensional geometry model into a model that can be
used in a dynamic simulation involves 3D modeling and volume analysis in CATIA,
development of a surrogate model from the analysis results in MATLAB and finally
development of a new tank model in Dymola.
2.2.1 Computer Aided Design (CAD) with CATIA
Based on the information from 3ds (2011a) CAD is the use of computer technology in the
process of design and design documentation. It is mainly used for detailed engineering of
3D models and 2D drawings of physical components. It can be used throughout the
whole engineering process, from conceptual design and layout of products, through
strength and dynamic analysis to definition of manufacturing methods. CAD is a useful
help as it lowers product development costs and shortens the design cycle, as design
changes can be easily done. Another advantage is that the design can be parameterized
and saved which enables it to be reused in other contexts. CAD is used in many
applications and industries, for example automotive and aerospace. It is also used to
produce animations for special effects in movies, advertising and technical manuals.
CATIA (Computer Aided Three dimensional Interactive Application) is a software
solution for product design and it supports the complete product development process.
CATIA comes with an embedded visual basic (VB) editor which allows the user to create
macros that automates the modeling. All available tools in CATIA are distributed in
different workbenches, some for modeling and others for analysis. The workbenches used
in this thesis work are:
 Generative shape design
 Part design
These workbenches together with the VB editor are used for creating a 3 dimensional
representation of the fuel in a tank and also for calculating fuel volume and fuel surface
location.
18
2.2.2 Data driven function approximation in MATLAB
Stated by Mathworks (2011) MATLAB is a highlevel technical language and interactive
environment for algorithm development, data visualization, data analysis and numeric
computation. MATLAB contains a lot of embedded functions but there are also a lot of
toolboxes available separately that provides more specialized functions, for example
advance curve fitting. The results can be visualized both in 2dimensional and in 3
dimensional graphs. The algorithms and the results are also easy to integrate with
external applications and other programming languages.
According to Queipo et al. (2005) many design problems require experiments and/or
simulations to evaluate how different parameters and constraints affect the results.
Sometimes these simulations can take long time to perform because of their complexity,
which makes them unsuitable for routine tasks such as design optimization and sensitivity
analysis as it require a lot of simulation evaluations.
One way of making these simulations computationally cheaper is to construct
approximation models, known as surrogate models, which imitated the behavior of the
original model but is less complex. Surrogate models are constructed using a datadriven
approach. The model is based on the input output behavior of the original model for
some chosen data points. The iterative process of modeling a surrogate model can be
divided in three steps:
Sample selection from the original model.
Construction of the surrogate model and optimization of the model parameters
Estimation of the accuracy of the surrogate model.
The accuracy of the surrogate model depends on the number and location of samples and
also on different sources of errors, such as noise in the data or because of the use of an
improper surrogate model. In this master thesis the surrogate modeling is about finding a
continuous function that explains the nonlinear input output behavior of the fuel motion
in a tank. According to Queipo et al. (2005), such a function can be created by using
different types of simple, locally linear models in different regions of the collected data,
which together build up an overall model of the system. There are different methods to
accomplish this. One option is to use radial basis functions (RBF) to approximate the
function.
19
Radial Basis Functions
According to Queipo et al. (2005) radial basis functions is used for interpolation of
scattered multivariate data. The method uses linear combinations of n
r
radially
symmetric functions placed at chosen centres to approximate a response function as
where x Є R
n
, Φ is a radial function, x
i
, 1≤ i ≤ n
r
,
are the RBF centres,
i
x x ÷ is the
Euclidean norm, the distance between these two points, w
i
, 1≤ i ≤ n
r
,
are the weights and
n
r
the number of centres. The functional form of Φ can be chosen among different radial
functions, in this master thesis the Gaussian function Φ(
i
x x ÷ ) = exp(k_i(
i
x x ÷ )
2
)
will be used. The surface generated by the Gaussian function looks like a bell, where the
constant k_i controls the width of the bell. By adding up a series of such bells a variety of
continuous surfaces can be well approximated. In figure 6 it is shown how the Gaussian
bells can be used for fitting a curve to a set of data points. When the training data have
been approximated with a surface that provides the best fit to the training data, the
surface can then be used for interpolating.
Figure 6 Curve fitting with Gaussian bells
According to Chen et al. (1990), the centres x
i
are either chosen to be a subset of the data
or distributed uniformly in the input domain, either distributed in a grid or having one
centre for each data point. In this master thesis the number of data is very large and to
include all the data as centres would give a large and complex model. To distribute the
centres in a grid may also provide an unnecessary number of centres and may not cover
the input domain properly. The same problem exists when arbitrarily choosing a sub set
of data points as centres. In order to select the most suitably centres among the data and
optimize the number, the orthogonal forward regression least squares algorithm is used.
Which is discussed in Chen, Billings & Luo (1989) Orthogonal least squares methods
and their application to nonlinear system identification. Starting from a large data set
with candidate centres, the algorithm sequentially selects the centre that results in the
largest reduction of the sumsquareerror between the RBF outputs and the training data.
When enough centres have been found to satisfy the allowed sumsquareerror the
selection process is aborted.
) ( ) (
1
i
i
i
x x
n
W x y
r
÷ u =
¿
=
20
As the training data from CATIA covers the whole design space and the allowed sum
squareerror is small the training data can be well approximated. In order to make the
calculation of the impact on the sumsquareerror for each new added centre more
efficient, the modified GramSchmidt orthogonalization is used to form an orthogonal
decomposition of the created matrix.
2.2.3 Dynamic simulation in Dymola
Ljung and Glad (2004) writes that a system is typically described by a number of
variables that change in time. If these variables can change without any direct external
influence and their value depends on its previous value, the system is called dynamic. In
a mathematical model the dynamic behavior is described by derivatives with respect to
time. A typical dynamic model consists of equations both with and without variables with
derivatives. These models are called differentialalgebraic equations models (DAE
model) and have to be solved numerical during simulation.
According to 3ds (2011b) Dymola is a tool for modeling and simulation of integrated and
complex systems. It makes it possible to simulate the dynamic behavior and the complex
interactions between different systems, such as mechanical, electrical, thermodynamic,
and hydraulic and their control systems. Models can be created both graphically, by drag
and drop or through the text editor.
Dymola uses the open Modelica modeling language for programming. As read on
Modelica (2011) Modelica is an equation based modeling language which is based on the
principals of objectoriented modeling, the use of simple standardized components to
build larger and more complex models. Modelica contains a model library with standard
model components, but the user is free to create their own libraries or modify the
readymade to better match their needs. The models are described by differential,
algebraic and discrete equations.
It is in Dymola the new 3dimensional tank model will be created and simulated to better
understand the dynamic movement of fuel and to calculate the hydrostatic pressure at an
inlet during simulation of a maneuvering aircraft.
21
3 Proposed methodology
In this chapter the different steps of this thesis work will be explained, from 3D modeling
in CATIA to dynamic simulation in Dymola.
3.1 Develop a 3D model of the fuel
As stated by Langton et al. (2009), fuel is stored in wing tanks on commercial aircraft,
but in high speed aircraft, wings are small and thin with little internal volume. The
fuselage is therefore used as fuel storage, but the fuselage is also filled with equipment
and weapon storage. So the remaining volume for fuel storage involves complex shapes
as can be seen in figure 7.
Figure 7 A typical fuel tank
According to Gavel (2007) the presence of subsystems in the tank also adds up to the
complexity of the model. Some of the subsystems that may be identified are engine feed,
fuel transfer, vent and pressurizing, refueling, measurement and management,
cooling and explosion protection systems. In figure 7 some of the equipment can be
spotted.
The space that is of interest is that between all this equipment, the compartment that is
filled with fuel. If this space is known the accurate volume and center of gravity for
different attitudes could be obtained. In order to get this specific volume a new solid has
to be created. A solid is the homogenous representation of an object. This new solid is
split by the different surfaces of the aircraft‟s body. Then all different parts such as pipes
and ribs, which are also represented as solid models, has to be removed, this is done by
the Boolean operator remove in the CAD tool. What is left is a complex shaped solid
which represents the volume of the fuel. Luckily this has already been done for most of
the fuel tanks at Saab.
22
3.2 Define the area of validity
The orientation of the fuel acceleration vector will change depending on the orientation
and the acceleration of the aircraft and the gravity. If the aircraft for example makes a
right turn there will be an acceleration force acting on the fuel in the opposite direction.
The orientation of the fuel acceleration vector is used in the volume analysis in CATIA,
which the final Dymola model is based on. To define the area of validity for the Dymola
model the allowed orientations of the fuel acceleration vector has to be set. This is done
by constraining the rotation around the three aircraft fixe axes shown in figure 8. The
rotation around the x axis is limited by ° ±¢ , ° ±u around the y axis and ° ±¢ around the
z axis. The orientations are changed in a specified number of steps and all possible
orientations within the limits are generated. To achieve this a basis vector n
s
(1) is rotated
around the three aircraft fixed axes by the basic rotation matrices (2) and the orientations
of the fuel acceleration vector n (3) is obtained. The size of this vector does not matter as
it is the direction of it which is of interest. In appendix 1 there is a MATLAB script
Orientation of fuel acc. that performs these operations.
(1)
(2)
(3)
 
s y x z
z
y
x
s
n R R R n
R
R
R
n
=
(
(
(
¸
(
¸
÷
=
(
(
(
¸
(
¸
÷
=
(
(
(
¸
(
¸
÷ =
=
1 0 0
0 ) cos( ) sin(
0 ) sin( ) cos(
) cos( 0 ) sin(
0 1 0
) sin( 0 ) cos(
) cos( ) sin( 0
) sin( ) cos( 0
0 0 1
1 0 0
¢ ¢
¢ ¢
u u
u u
¢ ¢
¢ ¢
23
Figure 8 The aircraft fixed coordinates
3.3 Volume analysis in CATIA
The idea is to obtain a data table of different volumes, the coordinates to a point on the
fuel surface and the coordinates to the center of gravity for that specific volume for
different orientations of the fuel acceleration vector. This table will be generated by
splitting up a solid, representing the fuel in the tank, in small parts and recording the data
of interest. This procedure will be repeated for different orientations of the fuel
acceleration vector.
The goal was to create and run all the operations in the analysis by the embedded visual
basic (VB) editor in CATIA. But due to missing workbenches, such as space analysis
(SPA), which should make it possible to insert measures through VB scripts and lack of
knowledge, some steps has to be done manually. In appendix 2 there is a guide on how to
access and use the created scripts in CATIA.
Tank models available at Saab contain a great deal of references and surfaces that were
used when the model was created, this makes the file quite big. When the first VB script
Copy the solid into a new part is executed the essential solid part body of the tank model
is copied into a new part in a new file. This is done in order to minimize the file size and
make the analysis run faster. The VB code for this operation can be found in appendix 3.
Before the script can be run the right name of the tank model has to be entered in the
script. The new part is opened in a new window and it contains just one body, containing
the solid, placed at the same coordinates as the original tank model, see figure 9. All
models created at Saab refer to the same coordinate system, whose origin is located in
front of the aircraft. When the new window is opened it will just show the coordinate
system but if the model is zoomed out or if the fittoall button is clicked the tank will be
visible.
24
Figure 9 The copied partbody opened in a new part in a new window.
The new body, named reference, will serve as a reference for the tank‟s center of gravity
which will be used to make sure that the different orientations that are going to be tested
starts from the same point. Also some measures from the bounding box and the total
volume of this body are needed for constructing the next steps of this analysis.
In the second VB script Prepare the model found in appendix 4 a point in the center of
gravity (CoG) is created and a copy of the reference body is made. It is on this new copy,
named fuel, that the analysis will be preformed. When all this is done a measure inertia
must be inserted manually on the reference body. How this is done is explained in
appendix 5, How to insert measures in CATIA. In figure 10 a screen shot from CATIA
shows the two bodies in the model tree, the point in center of gravity and the manually
inserted measure inertia.
25
Figure 10 Screen shot from CATIA showing the reference body, the fuel body and the point in the
center of gravity
VB script number three, Prepare the analysis in appendix 6, creates the references
needed for cutting the fuel body in smaller parts. It creates a line and a plane that moves
along this line and performs the cut. The line represents the orientation of the fuel
acceleration vector and will be changed according to all the generated orientations. The
line is created from a point reference and a given length. The point reference is the center
of gravity (CoG) created earlier and the length is set to the greatest dimension in the
bounding box of the reference body. This guarantees that the line will always go through
the whole body. By inserting a plane orthogonal to this line and fixed at a point that is
created on the line with a ratio condition between 0 and 1 (the ends of the line), a
movable cutting element is obtained. The plane will move when the ratio condition is
changed. What remains when the fuel body is cut are the representation of the amount of
fuel and the location of the fuel surface in the tank at the particular orientation. The result
from the analysis should be; fuel volume, coordinates for a point on the fuel surface and
the coordinates for the center of gravity of this fuel. Therefore a point with coordinates is
created on the moving plane with the ratio point as a reference. This means that the point
with coordinates will always be on the plane, which is representing the fuel surface. By
inserting measure inertia on the fuel body the volume and the coordinates for the center
of gravity can be received and by inserting a regular measure on the point on the plane
those coordinates can also be obtained. The result after script Prepare the analysis is
shown in figure 11.
26
Figure 11 Screen shot from CATIA showing the fuel acceleration vector and the cutting plane
The last VB script Run the analysis given in appendix 7 performs the analysis. The first
orientation of the fuel acceleration vector is loaded and the x, y and z components of the
line created in script number three is changed according to that orientation. In the
following forloop the cutting plane is moved along the line between the ratio 0, 5 and 0
with a defined number of steps, which are based on the desired volume difference
between two cuts defined by the user. The cutting plane starts from the center of the line,
from the center of gravity for the tank. In this way it is easy to detect when the cutting
plane has moved outside of the tank and no new volumes are formed. For each step the
fuel body is split and for the remaining body the volume, coordinates for the point on
surface and coordinates for the center of gravity are calculated and saved. Also the
corresponding fuel acceleration vector is saved. Figure 12 shows this cutting process.
When the cutting plane has moved outside of the body the forloop is aborted. For some
orientations of the fuel acceleration vector the number of volume cuts will be quite few,
resulting in large difference in volume between two cuts. This is because of the fixed
length of the line which the cutting plane moves along and the fixed step size for the
cutting plane. So when the forloop is aborted the number of performed cuts are
calculated and compared against a given minimum amount of cuts. If too few cuts have
been performed the cutting plane is moved once more along the line and the results are
calculated for the volumes between the previous cuts.
27
The same procedure is repeated for the other side of the fuel body, between ratio 0, 5 +
the step size and 1 on the line, shown in figure 13. If the model should fail to create the
divided body the number 99 is saved to the result file, this enables these errors to be
found and investigated. When a sufficient amount of cuts have been performed on the
body the orientation of the line is changed according to the next row in the input file and
the cutting process starts all over. The result is saved in a .txt file, because it is a basic file
format that can be opened and read by most tools for example MATLAB or Dymola. The
data in the .txt file is needed to create a mathematical model that can be used during
dynamic simulation.
Figure 12 The analysis process when the tank is being cut between ratio 0, 5 and 0
Figure 13 The analysis process when the tank is being cut between ratio 0, 5 + step size and 1
28
3.4 Develop a surrogate model
The thesis work is about finding a way of knowing the location and orientation of the fuel
surface depending on the orientation of the fuel acceleration vector and the amount of
fuel left in the tank. Favorably there should be a function that gives the x, y and z
components for a point on the fuel surface, from that the desired end results can be
calculated. In order to be able to use the result from CATIA in a dynamic simulation in
Dymola, a mathematical expression has to be found and implemented. This is done
through the use of radial basis functions (RBF) which has been implemented in
MATLAB and Dymola. The RBF approximation will be using the orientation of the fuel
acceleration vector and the volume as inputs to approximate a coordinate on the fuel
surface or in the center of gravity as output.
The data table from CATIA containing the orientations of the fuel acceleration vector,
volumes, coordinates to a point on the fuel surface and coordinates to the center of
gravity for each volume is imported to MATLAB and stored as a matrix. When the data
has been loaded the function rbf is executed with this matrix as input as well as the
choice of which point, fuel surface or center of gravity to approximate. The MATLAB
script can be found in appendix 8. The RBF is usually used for approximation of a single
value output, because that is easiest, so the x, y and z component for the two points are
calculated separately. By stepping through all the columns containing the point
coordinates and send these one by one together whit the data from CATIA as input for
another function, rbf_calc see appendix 9, the results; center points, weights, pre scaling,
output scaling and max volume can be calculated for each coordinate and saved in the
same file. The data is being saved in a format which is easy to access through Dymola.
The function rbf_calc removes all rows containing the number 99. These rows
correspond to errors from CATIA, when the model failed to create a divided body. The
point coordinate to be used as output in the RBF approximation is standardizes into a
vector of length one. This is done in order to balance the numerical values in the data,
which will lead to a better approximation.
The orientation of the fuel acceleration vector, volumes and the point coordinate is then
used in the function divide_data, appendix 10, together with the real constant that
controls the width of the bell shape of the Gaussian function used in this RBF
approximation. Increasing that value widens the bell. It is also in rbf_calc the acceptable
average residual between the training points and the calculated points are set. This
residual r in millimeters is used for calculating the tolerance tol (4), which is the sum of
standardized squared errors for the training data, n is the number of training data. The
residuals are standardized with the same length L as the point coordinates. This tolerance
is used for aborting the selection of centres.
¿
=
=
n
i
L r tol
1
2
) / ( (4)
29
Because of the large size of the matrix the calculations for finding the centres has to be
split into smaller sets, otherwise MATLAB will run out of memory. The function
divide_data is inspired by the fast Fourier transform algorithm. Basically it splits the data
D into two halves if the dataset is greater than 1000 points. It then makes two recursive
calls with D/2 as input. If the number of points is fewer than 1000 the data D/2 is send to
the function train_rbf found in appendix 11, where the centre selection is being
performed based on the set tolerance. If D/2 is greater than 1000, it makes some more
recursive calls with D/4, D/8 and so on. Once the points are fewer than 1000 and the data
has been trained and some centres have been chosen, these centres are sent back to the
previous hierarchical level. At this stage the obtained centres are being trained again and
the most suitable centres among these are being selected and sent to the next hierarchical
level. This repeats itself until all halves has been merged and the best centres that
describes the whole dataset has been chosen. The function train_rbf uses the function
sim_rbf, appendix 12, to calculate the output and the weights for the RBF approximation.
3.5 Implement the model in Dymola
Since there is already a tank model in Dymola, which calculates all the port properties
that are of interest, for example pressure and flow, the adaption to a 3 dimensional
representation is just a matter of minor modifications. The gravitation and acceleration
vectors have to be extended to 3 dimensions. The old rectangular representation and all 2
dimensional depending parameters have to be deleted. The RBF surrogate model is
implemented and the matrices created in MATLAB with chosen centres, weights and
scaling factors are imported to the model as parameters. In the setup for parameters it is
possible to choose the right data file for the current tank. Once the simulation is going,
based on the attitude of the aircraft and the given amount of fuel the model will calculate
the perpendicular distance between the fuel surface and all the ports. This distance is of
interest when to calculate the pressure at the ports. The calculations are done in a for
loop, from 1 to the number of RBF centres for one coordinate at the time. The point
coordinate is derived from the response surface created by the RBF approximation, which
is done in two steps. In the first step the Gaussian functions is calculated, where the sum
of squared distances between all chosen centre points and the input data (the orientation
of the normed acceleration vector and the current volume) is used according to (5).
2
1
:)) , 1 ( :) , ( ( ) 1 , ( exp( ) , 1 ( x i
n
ts centerPoin i preScaling i
r
i
÷ · ÷ = u
¿
=
(5)
In the next step the results are multiplied with the corresponding weights (6).
¿
=
u · =
n
W point
r
i 1
(6)
The result is then scaled by the scaling factor used for standardizing in the MATLAB
function rbf_calc. When the result has been scaled the coordinate now refers to the
original coordinate system used at Saab. These calculations are done for the x, y and z
coordinate. After this the parameter point contains the coordinates in millimeter for a
point on the fuel surface.
30
In order to calculate the distance between the surface and the ports, linear algebra with
geometry is used. The distance of interest is the shortest perpendicular distance between
the surface and the port. The port can be seen as a point P that has given coordinates and
the normal n to the fuel surfaces is the acceleration vector. By creating a vector QP
between the port and the calculated point Q on the fuel surface, the distance can be
calculated with u cos · = QP d , figure 14. If this equation is extended with the norm of n,
the numerator becomes the scalar between n and QP and the final equation is obtained
n
QP n
d
n
QP n
d
·
= ·
· ·
=
u cos
.
Figure 14 The calculation of the distance between the fuel surface and a port
All the distances heightToLevel between ports and the fuel surface is calculated in a for
loop and saved as a vector, abs g g point i on portPositi i vel heightToLe _ / ) ) :) , ( ((( ) ( · ÷ =
where g is the acceleration vector and g_abs the length of it. If the distance is positive the
port is below the fuel surface and if it is negative the port is above the fuel surface.
31
3.6 Verify port positions
In the old 2dimensional tank model there was a test that verified that the inserted ports
were within the tank geometry before the simulation could be performed. Very strange
results can be received from the simulation if the ports are not placed within the tank, so
this verification is crucial. That is why one of the objectives for this master thesis is to
construct a similar test for the new 3dimensional tank model. So that different port
positions can be tested in order to find the optimal placement without the risk of placing
them outside the tank.
One idea is based on the distance between ports and the planes that envelops the tank
geometry. These planes are the ones that indicate full volume for every orientation of the
fuel acceleration vector, in other words the planes that touch the geometry. By calculating
the distance to these planes, according to figure 14, the test shows that a port is within the
tank geometry if the distance is positive to all planes. This test gives a hint to if the port is
within the tank but the test is weak when it comes to convex surfaces. The problem is
visualized in figure 15, where the dashed area represents the area in which a port can be
recognized as within the tank when it is not.
Figure 15 The area in which a port can be recognized as within the tank when it is not
32
To be able to get a more precise verification, a test in CATIA is implemented instead. By
running the script Check ports, appendix 13, all coordinates to the ports are imported into
CATIA and a point is created at each of these coordinates. The coordinates to the ports
should be specified in a .csv file. Around each point a sphere is then created, which in
some sense represents the diameter of the inlets that the ports represents. By making
these spheres to solid bodies it is possible to check for intersections between these
spheres and the tank geometry. If there is an intersection it shows that the port is placed
within the tank and the name of this sphere will be the coordinates for it. If there is no
intersection the port is outside of the tank and the sphere is named with its coordinates
but also with “is outside the tank”. This together with the fact that everything is
visualized in CATIA makes it easy to see which ports that are okay and which that has to
be moved. This is shown in figure 16 where the red dots are the ports. The visualization
in CATIA also makes it easy to spot the ports that are on the border of the geometry with
half port within and the other half outside the tank. These ports will be interpreted as
within the tank by CATIA.
Figure 16 Verification of port position in CATIA
33
4 Results
In this chapter the results from each step is presented in aspects of both time
requirements and accuracy. The new 3dimensional tank model is simulated and the
results are compared against the old tank model.
4.1 Data processing
4.1.1 CATIA
The input to the CATIA analysis is the orientation of the fuel acceleration vector. It is
desirable to use as many orientations as possible in order to cover the aircraft‟s whole
maneuvering area. But in order to keep the number of orientations at a manageable level
the area of validity is restricted. Under normal conditions/normal maneuvering it is
acceptable to let the fuel acceleration vector change within ± 20° around the aircraft fixed
x coordinate, 360° around the y coordinate and ± 20° around the z coordinate. After early
test runs and consulting with the supervisor at Saab it was decided to let the orientation of
the fuel acceleration vector change in steps of 10°. This means that within the area of
validity there are 900 different orientations that are analyzed in CATIA.
The time requirements for performing the CATIA analysis and generate the data table is
depending on how detailed the tank model is and how big the desired volume difference
between two cuts are. For example if one of the detailed tank models of around 500 liters
are analyzed with an average step size of 18 liters it takes 24 hours and 19 975 executions
are performed in CATIA. The same tank is analyzed with an average step size of 12
liters, then 39 hours is required and 29 588 executions are performed. If a simple tank
model, containing fewer details, is analyzed in the same way it takes just three hours and
45 minutes to execute 35 676 operations. The file size of the detailed tank model is
around 20 MB and for the simple tank 0, 3 MB. The computer used for the analysis has a
2.53 GHz dual core processor and 12 GB in RAM.
4.1.2 MATLAB
When all the data from CATIA are to be trained and the RBF centres to be found, the
calculations done in MATLAB takes approximately 3 – 4 minutes for the point on the
fuel surface and for the center of gravity around 720 minutes. The calculations are done
on a 2, 93 GHz dual core computer with 4 GB in RAM. During these calculations the
tolerance for selecting centres is set to a value that corresponds with a volume error of
one liter between the recorded data and the calculated for each coordinate. To achieve
this tolerance approximately 900 basis functions is needed for the point on fuel surface
and 1200 basis functions for the center of gravity. If the tolerance is set to decrease the
volume error the time increases as more centres have to be found. It does not seem to be
any big difference in execution time, based on the amount of data to be trained but rather
the distribution of the data.
34
4.2 Resolution of the data
The biggest approximations are made in the volume analysis in CATIA when the fuel
volume is being cut. In each cut the exact volume and location of the fuel surface is
recorded, but between the cuts this information is not known. The values between the
cuts are being calculated from the response surface created by RBF, which makes a
smooth interpolation between the data points (volume cuts). This interpolation may cause
a difference between the actual volume and the calculated one, depending on how
irregular the fuel volume changes between the cuts. See figure 17. This problem also
exists between the different orientations of the fuel acceleration vector. If the volume
changes drastically directly after a cut the interpolated value will be way off as it
presumes that the volume changes linearly to the next cut. In order to get a hint of how
big this miscalculation caused by the interpolation may be, the maximum difference
between two data points from the analysis are investigated.
Figure 17 The interpolation problem between two cuts
By running the MATLAB script max_volume_error, appendix 14, the maximum volume
difference between two cuts as well as the average volume difference between cuts can
be seen. It is also displayed for which orientation of the fuel acceleration vector the
maximum volume difference is obtained. This enables the user to go back to the result
file from CATIA and find the reason for this difference. For the analyzed tanks the
average volume difference is around 18 liters, it varies depending on the orientation of
the acceleration vector and the shape of the tank. The biggest volume difference between
two cuts is quite big, up to around 140 liters on a tank of 300 to 500 liters. This is because
of the fixed step length during the volume analysis. The geometry of the tank, the cross
section area, gives that each step represents different volumes depending on the
orientation of the fuel acceleration vector. Also some volumes could not be calculated
during the analysis because of problems with reconstructing some of the surfaces on the
tank model. This means that some data are missing and the step length between two cuts
are twice as far as it should be, which results in a big difference in volume between the
cuts. However this may not affect the model that much, by investigating the data from
CATIA the case for which this maximum difference occurred can be found and avoided
during simulation. There is also one possibility that the nearby data points from the other
orientations of the fuel acceleration can make the interpolation quite accurate even for the
case with the big volume difference.
35
Because of the relatively big volume difference between the data points obtained from
the volume analysis in CATIA there is no need to make the RBF approximation a perfect
match to the recorded data points. A residual equal to one liter for each coordinate is
acceptable. The allowed residual r (mm) in the RBF approximation is calculated by
dividing the acceptable volume error (1 liter) with the ratio of the average volume
difference Mm (m
3
) and the step length L (mm), equation 7. The step length between two
cuts can be read in the header of the result file from CATIA and the average volume
difference between two cuts is calculated using the MATLAB script max_volume_error.
The allowed residual will change depending on which tank is used.
L
Mm
r
1000
1
·
= (7)
4.3 Model simulation in Dymola
4.3.1 Test system
In order to test the performance and validate the results for the new 3dimensional tank
model, a simple test system was designed in Dymola. It consists of the tank model, a
system component that specifies the acceleration and a source component with table data
of the time depending orientation of the acceleration vector. The system can be seen in
figure 18.
Figure 18 The test system for the new 3dimensional tank model
36
4.3.2 Performance
To test the performance of the new 3dimensional tank model, a number of simulations
were preformed on the test system, with different simulation times and with an
acceleration vector that alters during the whole simulation, causing the fuel surface to
move around. The same system with the same input but with the old 2 dimensional tank
model is also simulated and the difference in CPU time for simulation is compared. The
simulations are performed on a 2, 93 GHz dual core computer with 4 GB in RAM
The time for compilation and simulation of the new 3 dimensional tank, using 1009 RBF
centres to calculate the fuel level, was almost three times as long as with the old 2
dimensional tank. The system was also tested with a 3dimensional tank that used only
385 RBF centres which made the time only one third longer compared with the 2
dimensional tank. When the test system was extended to include four different 3
dimensional tanks, using 757, 355, 1007 and 385 RBF centres, the time did not increase,
but remained at a time comparable with just one 3dimensional tank.
A more realistic case was also tested. The whole fuel system was simulated with a real
flight case, with maneuvering and fuel consumption. When the old 2 dimensional tanks
were used the time for simulating 450 seconds took approximately 10 minutes plus one
minute for compilation. When the 3 dimensional tanks with 757, 355, 1007 and 385
RBF centres were used the time increased to 30 minutes plus 10 minutes for compilation.
4.4 Validation against measured data
The accuracy of the new 3 dimensional tank model was tested by simulating the distance
between the fuel surface and three scattered ports and then comparing the result with
measures from the actual geometry model in CATIA. The difference in distance was then
translated into the amount of fuel it represents. The results were also compared against
the results from the old 2 dimensional tank model in order to see how great the
improvement is. The results can be seen in table 1. The acceleration vectors used during
these tests where all within the area of validity. Some of them where the same vectors
used for generating the data in CATIA and some are vectors between these.
The used models where:
The geometry model in CATIA (CAD)
The 3dimensional tank model in Dymola, based on data with a resolution of
approximately 18 liters between the data points (3D.18)
The 3dimensional tank model in Dymola, based on data with a resolution of
approximately 12 liters between the data points (3D.12)
The old 2 dimensional tank model in Dymola (2D)
37
Table 1Comparison between the results from the different models
Port (7.889, 0.318, 3.819) m
Acceleration vector CAD 3D.18 3D.12 2D CAD3D.18 CAD3D.12 CAD2D CAD3D.18 CAD3D.12 CAD2D
0.095492,0.29389,0.95106 98 102 107 71 4 9 27 4 6 18
0.43388,0.14094,0.88988 99 98 96 84 1 3 15 0 1 10
0,0,1 55 43 49 127 12 6 72 10 5 59
0.78183,0.097535,0.61581 18,7 23 21 63 4,3 2,3 44,3 2 1 22
0.095492,0.29389,0.95106 89 81 82 71 8 7 160 6 5 11
0.20074,0.28944,0.93591 105 107 108 116 2 3 11 1 1 7
0.89371,0.22689,0.38705 86 88 89 112 2 3 198 0,5 0,5 89
0.11698,0.32139,0.93969 103 108 112 69 5 9 34 3 5 22
Port (8.122, 0, 3.57) m
Acceleration vector CAD 3D.18 3D.12 2D CAD3D.18 CAD3D.12 CAD2D CAD3D.18 CAD3D.12 CAD2D
0.095492,0.29389,0.95106 219 223 228 295 4 9 76 4 6 40
0.43388,0.14094,0.88988 377 376 374 410 1 3 33 0 1 24
0,0,1 304 292 298 376 12 6 72 10 5 59
0.78183,0.097535,0.61581 21 25 23 34 4 2 13 2 1 7
0.095492,0.29389,0.95106 218 227 226 295 9 8 77 6 5 41
0.20074,0.28944,0.93591 199 201 202 311 2 3 112 1 1 58
0.89371,0.22689,0.38705 289 289 287 425 0 2 136 0 0,5 63
0.11698,0.32139,0.93969 207 213 217 288 6 10 81 3 5 38
Port (8.298, 0.4, 4.27) m
Acceleration vector CAD 3D.18 3D.12 2D CAD3D.18 CAD3D.12 CAD2D CAD3D.18 CAD3D.12 CAD2D
0.095492,0.29389,0.95106 580 577 572 420 3 8 160 4 6 72
0.43388,0.14094,0.88988 226 227 229 142 1 3 84 0 1 59
0,0,1 396 408 402 324 12 6 72 10 5 59
0.78183,0.097535,0.61581 509 505 506 538 4 3 29 2 1 14
0.095492,0.29389,0.95106 348 338 339 420 10 9 72 6 5 61
0.20074,0.28944,0.93591 608 605 604 411 3 4 197 1 1 87
0.89371,0.22689,0.38705 267 266 265 308 1 2 41 0 0,5 20
0.11698,0.32139,0.93969 600 594 590 429 6 10 171 3 5 71
Distance between fuel surface
and port (mm)
Difference (mm)
Difference (mm)
Difference (mm)
Distance between fuel surface
and port (mm)
Distance between fuel surface
and port (mm)
Difference (kg)
Difference (kg)
Difference (kg)
This test shows that the 3 dimensional tank model based on data with a resolution of 18
liters between the data points are almost as good as the one based on 12 liters between the
data points. The difference in amount of fuel between the measures from the geometry
model and the 3 dimensional tank model (3D.18) is in average 3, 3 kg and for the
geometry model and the other 3 dimensional tank (3D.12) the difference is 3, 1 kg.
When comparing these results against the results from the old 2 dimensional model
which in average differed 42, 1 kg, it is shown that there is a big improvement.
It should be mentioned that the results for the 3 dimensional tank model did not get
remarkable better when the accuracy for the centre selection in the RBF approximation
was increased.
38
4.5 Supported tank geometries
The methodology has been developed to support any kind of 3 dimensional geometry as
the shape of the tanks used at Saab varies a lot. The developed methodology has been
used to create 3 dimensional tank models in Dymola, representing some of the available
tank geometries at Saab. Some of the tested geometries are shown in figure 19.
Figure 19 Examples of tested geometries
39
5 Conclusions
In this chapter different aspects of the proposed methodology are analyzed and potential
improvements and areas of further development are presented.
5.1 Discussion and conclusions
The purpose of this master thesis was to investigate and develop a methodology for using
3dimensional CATIA models in simulations in Dymola. The result, the new 3
dimensional tank model in Dymola is a proof that it is possible to transform CAD data
into a model that can be used in a dynamic simulation. The proposed methodology is one
way of doing this and as the results shows the outcome is acceptable.
It is important to remember that there have been assumptions and simplifications in every
step of this developed methodology. This means that the results from the simulation do
not fully correspond to the real system but they are good enough. A big advantage with
this methodology is that it is possible to determine how accurate the model is compared
to the CAD model. This is of great help when to interpret the results from the simulation.
In order further verify the model the results should be compared against the results from a
real test flight.
Based on the measured result the conclusion can be drawn that the 3dimensional tanks
does give a better approximation of the reality than the old 2dimensional. This in turn
gives the possibility to perform more accurate pressure and flow calculations on the fuel
system. Moreover the presented framework enables calculation of unused fuel in the tank
and the possibility to better calculate the aircraft‟s center of gravity. With the new 3
dimensional representation it is also possible to find the best placement for fuel probes,
intake and venting ports as the location of the fuel surface is better known.
The developed methodology reduces the difficulties and the approximation errors that
occur when modeling the tanks as rectangular blocks, all ports can be placed at their
original positions and the result is equally good for all orientations of the fuel
acceleration vector. The only restriction is the area of validity; the results are only
credible inside the given angles for the fuel acceleration vector. It is possible that these
restrictions are set to narrow, but it seems that most test flight cases are within the area of
validity. Outside of these restrictions the results cannot be trusted as the RBF has
problems extrapolating the needed response surface.
One problem with the found methodology is that the analysis in CATIA takes a lot of
time. For the tested tank geometries, which has a file size of approximately 20MB after
the simplification done by script Copy the model, the time for generating the data table is
around 20 hours. This means that the time for running the analysis on more detailed tank
models in CATIA will be way too long as the detailed models can be as much as four
times greater than the tested ones. The problem with this is not just the time but also the
fact that CATIA uses all available RAM and during the analysis this memory is never
released causing the computer to crash.
40
With more powerful computers, these problems would be smaller but that is not the right
action to take. Two more preferable ways of getting around the problem is to simplify the
tank models even further and the other is to run the analysis in batches.
As other simplifications are made in the methodology perhaps the original tank model
does not need to be 100 % accurate. If a good enough approximation of the tank models
could be made, the file size and the execution time could be heavily reduced and the
result would still be better than the rectangular representation. This could be made by
some sort of wraparound technique, which results in a rougher model with fewer
surfaces. This is discussed by Seo et al. (2005). The model verification shows that even
the simulation based on fewer executions in CATIA resulted in good accuracy. Maybe it
is possible to reduce the number of executions in CATIA, investigating fewer
orientations and/or volumes in order to shorten the execution time.
If none of the above is possible there is the option to create a program that runs the
volume analysis in CATIA in batches. Simply the program should start CATIA, load a
subset of orientations for the fuel acceleration vector and execute the analysis macro. In
order to make this work the first macros has to be run manually as there are manual steps
in them. When that is done the model could be saved and the created “batch program”
could be used. When the first batch is done, the program should restart CATIA and load
it with a new batch. In this way CATIA will execute the analysis pretty fast as it operates
with a lot of available RAM memory at all time. How to execute CATIA scripts in batch
mode is discussed by CATIA V5 Automation (2011).
There is also a problem with the fixed step size during the volume analysis since each
step represents different amount of fuel depending on the tank geometry and the
orientation of the acceleration vector. This means that the accuracy in the model varies
during a flight case. With the criteria of a minimum amount of cuts for each orientation
this is solved to some extent. However the best way of solving this is to use a bounding
box around the tank and for each orientation the line is adjusted to fit inside this bounding
box. Then the step size could be adjusted so that each step represents equal amount of
fuel. It would also be possible to get the desired data from a complete full and empty
tank. As it is now, the data recording is aborted when the cutting plane has moved outside
the tank. This leads to the fact that the last recorded data has the value from the last cut
that was within the tank. This bounding box method should be created so that it does not
affect the execution time negatively. The existing problem with the step size also makes
it hard to set the desired average volume between two cuts. It seems that the results
always contain a larger average volume step than the set one.
In the old 2 dimensional tank model in Dymola there was an animation of how the fuel
moved around and decreased in the tank. A similar animation for the new 3dimensional
tank should be of interest and it is possible to export the visualization information from
CATIA by converting the CATIA model into an STL file. In Dymola a BodyShape can
be used to represent a body. This body can then be represented by different available
standard shapes or it can refer to CAD data for visualization.
41
Another option is to let CATIA take care of the animation, by linking the result from the
simulation to the tank model in CATIA. This feature is available in CATIA V6, where
Dymola is integrated into CATIA. If the animation is done in Dymola it could also be
used for the verification of port positions, to check if they are within the tank geometry
before the simulation is performed. If all ports are represented by some sort of shape they
will be visible in the animation window and it should be easy to detect if any of them by
accident has been moved outside the tank. If the verification of port positions is to be
performed mathematically by calculating the distance from the planes that encapsulate
the tank and the ports, the problem with convex surfaces has to be solved and also more
planes has to be created in order to encapsulate the entire tank.
The objective of creating a technology demonstrator for Dassault Systèmes has been
accomplished, but it would have been more appropriate if everything was done in CATIA
and Dymola. One alternative to accomplish this is to let Dymola searches through the
created data table, the result from CATIA, to find a matching value each time the
orientation of the fuel acceleration vector or volume is changed in the simulation. This
should work but would take longer time as the table is very big and the interpolation is
done in a four dimensional space. Perhaps it is even possible to develop a similar
surrogate model which was done in MATLAB directly in Dymola. This is left to be
investigated by Dassault Systèmes.
During the simulation on the entire fuel system it becomes very demanding for Dymola
when the fuel level is stationary at an inlet. The reason is that the medium at that inlet
changes between fuel and air constantly which causes the calculations to slow down as
smaller time steps has to be taken. If this can be solved, the CPU time for simulating the
3dimensional tank models could become comparable with the old 2dimensional.
In almost every step of the proposed methodology there is a tradeoff between accuracy
and execution time. It would be desirable to find the best tradeoff by experimenting with
the parameters that are possible to change, for example the number of executions in
CATIA, the shape of the Gaussian bells and the residual used when selecting centres
etcetera. The major questions are how big the gap between two data points from CATIA
can be and how many centre points that are needed for the RBF before the accuracy of
the model in Dymola becomes to poor. There is a possibility that each tank has its own
optimal parameter settings as the shape of the tank differs. This has to be further
investigated.
42
43
References
Printed
Brooks. R & Robinson. S ( 2001) Simulation. Palgrave, Operational Research Series.
ISBN 0794303
Gavel. H (2007) On Aircraft Fuel Systems – Conceptual Design and Modeling.
Dissertation No.1067, Division of Machine Design, Department of Mechanical
Engineering, Linköpings University. ISBN 9789185643042
Johannesson. H, Persson. JG & Pettersson. D (2004) Produktutveckling  effektiva
metoder för konstruktion och design. Liber AB. ISBN 9147052252
Langton. R, Clark. C, Hewitt. M & Richards. L (2009) Aircraft Fuel Systems. John Wiley
and Sons, Ltd. ISBN 9781563479632
Ljung. L & Glad. T ( 2004) Modellbygge och simulering. Studentlitteratur, Lund, andra
upplagan. ISBN 9144024436
Ullman. D.G (2003) The Mechanical Design Process, Third Edition. The McGrawHill
Companies, Inc. ISBN 0071122818
Papers
Chen. S, Billings. S.A & Lou. W (1989) Orthogonal least squares methods and their
application to nonlinear system identification. Internal Journal of Control, 50:5, 1873 
1896
Chen. S, Billings. S.A, Cowan. C.F.N & Grant. P.M (1990) Practical identification of
NARMAX models using radial basis functions. Internal Journal of Control, 52:6, 1327 
1350
Diston. J.D, Tookey. M.R & Spicer. G.M MultiDisciplinary Modelling for System
Integration. BEA Systems plc, Warton Aerodrome, Preston PR4 1AX, UK
Lind. I & Andersson. H (2011) Model Based Systems Engineering for Aircraft Systems –
How does Modelica Based Tools Fit? In proceedings of the 8th International Modelica
Conference, Dresden, 2011
Seo. J, Song. Y, Kim. S, Lee. K, Choi. Y & Chae. S (2005) Wraparound operation for
multiresolution CAD model, ComputerAided Design & Applications, Vol. 2, Nos. 14,
pp. 6776
Queipo N.V., Haftka R.T., Shyy W., Goel T., Vaidyanathan R.& Tucker P.K. (2005)
Surrogatebased analysis and optimization. Progress in Aerospace Sciences, Vol. 41,
Elsevier, pp. 128
44
Electronic
3ds (2011a) Design Excellence for Product Success,
http://www.3ds.com/fileadmin/PRODUCTS/CATIA/PDF/CATIAbd.pdf
Viewed 11/4/2011
3ds (2011b) Dymola,
http://www.3ds.com/products/catia/portfolio/dymola/overview/
Viewed 2/6/2011
CATIA V5 Automation (2011) Executing CATIA scripts in batch mode,
http://v5vb.wordpress.com/2010/09/26/execscriptsinbatchmode/
Viewed 29/8/2011
Mathworks (2011) Matlab,
http://www.mathworks.com/products/matlab/description1.html
Viewed 2/6/2011
Modelica (2011) Modelica,
https://www.modelica.org/
Viewed 6/6/2011
Verbal
Feng. X, ABB (2011) Model driven Design and Optimization of Industrial Robots at
ABB. Presented during 5th MODPROD Workshop on ModelBased Product
Development. Linköping 89 February, 2011.
Thorp. A, Enginsoft Nordic AB (2011) Multiobjective optimization using
modeFRONTIER. Presented during 5th MODPROD Workshop on ModelBased Product
Development. Linköping 89 February, 2011.
45
Appendix
Appendix 1. Orientation of fuel acc. (MATLAB function)
%Generates a csv file with the components of the acceleration vector.
%Based on angle changes, rotation in 3 dimensions.
phi = linspace(pi/9,pi/9,5)'; %angle between y and z, +/ 20 degrees
split in 5 steps (steps of 10 degrees)
theta = linspace(pi,pi,36)'; %angle between x and z, +/ 180 degrees
split in 36 steps(steps of 10 degrees)
psi = linspace(pi/9,pi/9,5)'; %angle between x and y, +/ 20 degrees
split in 5 steps(steps of 10 degrees)
Vs = [0 0 1]'; %starting vector
V = [];
%Generates all possible combinations of phi,theta and psi
for i = 1:size(phi,1)
Rx = [1 0 0;0 cos(phi(i)) sin(phi(i));0 sin(phi(i)) cos(phi(i))];
for j = 1:size(theta,1)
Ry = [cos(theta(j)) 0 sin(theta(j));0 1 0;sin(theta(j)) 0
cos(theta(j))];
for k = 1:size(psi,1)
Rz = [cos(psi(k)) sin(psi(k)) 0;sin(psi(k)) cos(psi(k))
0;0 0 1];
temp = [Rz*Rx*Ry*Vs]'; %rotation in 3 dimensions
V = [V;temp];
end
end
end
csvwrite('accVector.csv',V)
%Saves the data in the matrix V in a csv file in your working directory
%The name of the file is accVector
46
Appendix 2. How to access scripts in CATIA
The VB macros is accessible though the top menu in CATIA under Tools → Macro →
Macros. In order to be able to use the scripts, the folder in which they are stored must be
added as a library in CATIA. This is only necessary the first time you open these scripts.
To add a new library click on the “Macro libraries” button and a new dialog box opens.
Click the button “Create new library” and enter the path to the right folder. The scripts
will now be visible and you can run them by simply choose one of them and click “Run”.
47
Appendix 3. Copy the solid into a new part (CATIA script)
'THIS SCRIPT COPIES THE PARTBODY FROM THE ORIGINAL TANK MODEL INTO A
'NEW PART, WHICH IS OPENED IN A NEW WINDOW. BY DOING THIS THE FILE SIZE
'IS HEAVILY REDUCED AND THE TIME FOR RUNING THE ANALYSIS WILL ALSO BE
'REDUCED.
Sub CATMain()
' CREATE A NEW PART 
Set documents1 = CATIA.Documents
Set partDocument1 = documents1.Add("Part")
Set specsAndGeomWindow1 = CATIA.ActiveWindow
specsAndGeomWindow1.WindowState = catWindowStateNormal
Set windows1 = CATIA.Windows
Set specsAndGeomWindow2 = windows1.Item("FUEL TANK 3.CATPart") 'THE ITEM " "
SHOULD BE THE NAME OF THE ORIGINAL TANK FILE
specsAndGeomWindow2.Activate
' COPY THE PARTBODY FROM THE ORIGINAL TANK MODEL 
Set partDocument2 = CATIA.ActiveDocument
Set selection1 = partDocument2.Selection
selection1.Clear
Set part1 = partDocument2.Part
Set bodies1 = part1.Bodies
Set body1 = bodies1.Item("PartBody")
selection1.Add body1
selection1.Copy
48
' INSERT THE COPY IN THE NEW PART 
specsAndGeomWindow1.Activate
Set part2 = partDocument1.Part
Set selection2 = partDocument1.Selection
selection2.Add part2
selection2.PasteSpecial("CATPrtResultWithOutLink")
selection1.clear
selection2.clear
' RENAME THE NEW PART TO "TANK FOR ANALYSIS" 
Set product1 = partDocument1.GetItem("Part2")
product1.PartNumber = "Tank for analysis"
' RENAME THE COPIED BODY TO "REFERENCE" 
i = partDocument1.part.Bodies.Count
Set BodyToRename = partDocument1.part.Bodies.Item(i)
BodyToRename.name = "reference"
part2.Update
End Sub
49
Appendix 4. Prepare the model (CATIA script)
'THIS SCRIPT CREATES A NEW GEOMETRICAL SET IN WHICH ALL 'REFERENCES
FOR THE ANALYSIS WILL BE STORED. IT ALSO CREATES A 'POINT IN THE CENTER
OF GRAVITY OF THE REFERENCE BODY AND 'COPIES THE REFERENCE BODY TO A
NEW BODY ON WHICH THE ANALYSIS 'WILL BE PREFORMED.
Sub CATMain()
' CREATE GEOMETRICAL SET 
Set documents1 = CATIA.Documents
Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part
Set hybridBodies1 = part1.HybridBodies
Set hybridBody1 = hybridBodies1.Add()
hybridBody1.name = "Analysis_References"
part1.UpdateObject hybridBody1
' CREATE COORDINATE POINT 
Set hybridShapeFactory1 = part1.HybridShapeFactory
Set coordinatepoint = hybridShapeFactory1.AddNewPointCoord(0.000000, 0.000000, 0.000000)
Set arm_ref = part1.HybridBodies.Item("Analysis_References")
arm_ref.AppendHybridShape coordinatepoint
part1.Update
' CREATE DATUM POINT "CoG" 
Set coordpkt_ref = part1.CreateReferenceFromObject(coordinatepoint)
Set datumpoint = hybridShapeFactory1.AddNewPointDatum(coordpkt_ref)
arm_ref.AppendHybridShape datumpoint
hybridShapeFactory1.DeleteObjectForDatum coordpkt_ref
datumpoint.name = "CoG"
50
' MOVE DATUM POINT TO CENTER OF GRAVITY 
Set COGpointparameter = part1.Parameters.Item("CoG")
Set formula1 = part1.Relations.CreateFormula("COG_Formula", "", COGpointparameter,
"centerofgravity(reference)")
formula1.Hidden = True
part1.Update
' COPIES REFERENCE BODY TO A NEW BODY 
Set selection1 = partDocument1.Selection
Set selection2 = partDocument1.Selection
selection1.Clear
Set bodies1 = part1.Bodies
Set body1 = bodies1.Item("reference")
selection1.Add body1
selection1.Copy
selection2.Add part1
selection2.PasteSpecial("CATPrtResultWithOutLink")
selection2.Clear
selection1.Clear
part1.Update
' RENAME THE NEW BODY TO "fuel" 
i = partDocument1.part.Bodies.Count
Set BodyToRename = partDocument1.part.Bodies.Item(i)
BodyToRename.name = "fuel"
part1.Update
51
' HIDES THE REFERENCE BODY AND 
' REMINDES THE USER OF INSERTING A MEASURE 
selection1. Add body1
Set vispropset1 = selection1.VisProperties
VisPropset1.SetShow catvispropertynoshowattr
part1.Update
msgBox("Insert a Measure Inertia on the reference body and rename it to inertia_reference")
End sub
52
Appendix 5. How to insert measures in CATIA
There are two types of measures in CATIA, measure inertia and measure between. Both
will be used and are therefore explained. This step by step guide is direct ly applicable to
the steps that are to be done manually in this master thesis.
To insert measure inertia on a body:
1. Click the “measure inertia” button in the bottom toolbar.
2. Choose which body you want to measure by clicking on the geometrical
representation or at the name in the structure tree on the left. Then the dialog box
seen in figure 1appears.
Figure 1 Measure Inertia Figure 2 What to calculate
3. Click on the button “Customize” and a new dialog box appears. Make sure that
volume, center of gravity and principal axes are checked see figure 2. Then “OK”.
4. Make sure that “Keep measure” is checked in figure 1 and then “OK”
5. The measures have now appeared in the structure tree. To change the name of it
just right click on it and choose “properties”. See figure 3.
The measure on the reference body should be named inertia_reference and the measure
on the fuel body should be named inertia_fuel .
53
Figur 3 How to find properties
To insert a measure on the point_on_fuel_surface:
1. Click the “measure between” button in the bottom toolbar.
2. Choose point_on_fuel_surface from the structure tree. Then the dialog box seen in
figure 4 appears.
Figur 4 Measure Item
3. Make sure that “Keep measure” is checked in figure 4 and then “OK”
54
4. The measures have now appeared in the structure tree. To change the name of it
just right click on it and choose “properties”, as in figure 3.
5. To hide the measures from the geometrical model right click on the measure you
want to hide and choose “Hide/Show”, figure 5
Figur 5 Hide/Show
55
Appendix 6. Prepare the analysis (CATIA script)
'THIS SCRIPT CREATES ALL LINES, POINTS, PLANES AND CUTING 'ELEMENTS
THAT WILL BE USED DURING THE ANALYSIS.
Sub CATMain()
'
Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part
Set hybridBodies1 = part1.HybridBodies
Set hybridBody1 = hybridBodies1.Item("Analysis_References")
Set hybridShapes1 = hybridBody1.HybridShapes
Set parameters1 = part1.Parameters
' CALCULATE THE GREATEST DISTANCE IN 
'THE BOUNDING BOX FOR THE TANK 
Set lengthx = parameters1.Item("Tank for analysis\inertia_reference\BBLx") 'THE ITEM " "
MUST MATCH THE NAME OF THE PART
Set lengthy = parameters1.Item("Tank for analysis\inertia_reference\BBLy") 'THE ITEM " "
MUST MATCH THE NAME OF THE PART
Set lengthz = parameters1.Item("Tank for analysis\inertia_reference\BBLz") 'THE ITEM " "
MUST MATCH THE NAME OF THE PART
lengthxy = ((lengthx.value^2 + lengthy.value^2)^(1/2))
lengthyz = ((lengthy.value^2 + lengthz.value^2)^(1/2))
lengthxz = ((lengthx.value^2 + lengthz.value^2)^(1/2))
if lengthxy >= lengthyz And lengthxy >= lengthxz then
length = lengthxy
Elseif lengthyz >= lengthxy And lengthyz >= lengthxz then
length = lengthyz
Else
length = lengthxz
End if
56
' CREATE A LINE THAT IS FIXED AT CoG AND HAS A 
' FIXED LENGTH OF THE GREATEST DISTANCE IN THE BOUNDING BOX 
Set hybridShapeFactory1 = part1.HybridShapeFactory
Set hybridShapePointOnCurve1 = hybridShapes1.Item("CoG")
Set hybridShapeDirection1 = hybridShapeFactory1.AddNewDirectionByCoord(0, 0, 1)
Set axisSystems1 = part1.AxisSystems
Set axisSystem1 = axisSystems1.Item("Absolute Axis System")
Set reference1 = part1.CreateReferenceFromObject(hybridShapePointOnCurve1)
Set reference2 = part1.CreateReferenceFromObject(axisSystem1)
hybridShapeDirection1.RefAxisSystem = reference2
Set hybridShapeLinePtDir1 = hybridShapeFactory1.AddNewLinePtDir(reference1,
hybridShapeDirection1, length/2, length/2, False)
hybridBody1.AppendHybridShape hybridShapeLinePtDir1
hybridShapeLinePtDir1.name = "acc_vector"
part1.Update
' CREATE A REFERENCE POINT ON THE LINE "acc_vector" 
Set hybridShapeLinePtDir2 = hybridShapes1.Item("acc_vector")
Set reference3 = part1.CreateReferenceFromObject(hybridShapeLinePtDir2)
Set hybridShapePointOnCurve2 =
hybridShapeFactory1.AddNewPointOnCurveFromPercent(reference3, 0.0, False)
hybridBody1.AppendHybridShape hybridShapePointOnCurve2
hybridShapePointOnCurve2.name = "point_reference"
part1.Update
' CREATE A PLANE, NORMAL TO THE LINE "acc_vector" 
'  AND FIXED AT THE POINT "point_reference"
Set reference4 = part1.CreateReferenceFromObject(hybridShapeLinePtDir2)
Set reference5 = part1.CreateReferenceFromObject(hybridShapePointOnCurve2)
57
Set hybridShapePlaneNormal1 = hybridShapeFactory1.AddNewPlaneNormal(reference4,
reference5)
hybridBody1.AppendHybridShape hybridShapePlaneNormal1
hybridShapePlaneNormal1.name = "fuel_level"
part1.Update
' CREATE A POINT ON THE FUEL SURFACE WITH X,Y,Z COORD 
Set hybridShapePointCoord1 = hybridShapeFactory1.AddNewPointCoord(0.000000, 0.000000,
0.000000)
Set reference6 = part1.CreateReferenceFromObject(hybridShapePointOnCurve2)
hybridShapePointCoord1.PtRef = reference6
Set reference7 = part1.CreateReferenceFromObject(axisSystem1)
hybridShapePointCoord1.RefAxisSystem = reference7
hybridBody1.AppendHybridShape hybridShapePointCoord1
hybridShapePointCoord1.name = "point_on_fuel_surface"
part1.Update
' SPLIT THE BODY "fuel" WITH THE CREATED PLANE 
' AND REMIND THE USER TO INSERT MEASURES 
Set shapeFactory1 = part1.ShapeFactory
Set reference8 = part1.CreateReferenceFromName("")
Set split1 = shapeFactory1.AddNewSplit(reference8, catPositiveSide)
Set reference9 = part1.CreateReferenceFromObject(hybridShapePlaneNormal1)
split1.Surface = reference9
part1.Update
msgBox("Insert a Measure Inertia on fuel and rename it to inertia_fuel. Also measure the
point_on_fuel_surface, name it point_on_fuel_surface ")
End Sub
58
Appendix 7. Run the analysis (CATIA script)
'THIS SCRIPT IMPORTS COORDINATES FROM A CSV FILE AND CHANGES THE
'ORIENTATION OF THE LINE "acc_vector". IT ALSO EXECUTES A FOR LOOP THAT
'MOVES THE CUTTING PLANE ALONG THIS LINE AND SPLITES THE BODY "fuel".
'FROM EACH CUT THE VOLUME OF THE REMANING BODY, THE COORDINATES
'FOR THE POINT ON THE FUEL SURFACE AND THE COORDINATES FOR THE
'CENTER OF GRAVITY IS RECORDED AND SAVED IN A TXT FILE.
Sub CATMain()
'
Set oFileSys = CATIA.FileSystem
Set oFile = oFileSys.GetFile("H:\My Documents\CAD\Ny indata\accVector.csv") 'THE
LOCATION OF THE CSV FILE WITH THE ORIENTATIONS OF THE ACCVECTOR
Set Stream = oFile.OpenAsTextStream("ForReading")
Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part
Set bodies1 = part1.Bodies
Set body1 = bodies1.Item("fuel")
Set selection1 = partDocument1.Selection
selection1. Add body1
Set vispropset1 = selection1.VisProperties 'HIDES THE FUEL BODY TO SPEED UP
CALCULATIONS
VisPropset1.SetShow catvispropertynoshowattr
part1.Update
' THE PARAMETERS ARE SET. THE ITEM MUST MATCH THE NAME OF THE
'PART 
Set parameters1 = part1.Parameters
Set realParam1 = parameters1.Item("Tank for analysis\Analysis_References\acc_vector\X")
Set realParam2 = parameters1.Item("Tank for analysis\Analysis_References\acc_vector\Y")
Set realParam3 = parameters1.Item("Tank for analysis\Analysis_References\acc_vector\Z")
Set ratio = parameters1.Item("Tank for analysis\Analysis_References\point_reference\Ratio")
Set volume_ref = parameters1.Item("Tank for analysis\inertia_reference\Volume")
59
' CREATES AND OPENS THE RESULT FILE 
filename = CATIA.FileSelectionBox("Where do you want to save the result file", "*.txt",
CatFileSelectionModeSave)
Set Datos = CATIA.FileSystem.CreateFile(filename & ".txt" , True)
Set ostream = Datos.OpenAsTextStream("ForAppending")
' THE NUMBER OF STEPS THAT THE LINE "acc_vector" WILL BE DEVIDEED INTO 
averageVolumeError = 10 'LITERS
StepSize = 1/((volume_ref.value*1000)/averageVolumeError) 'MAKES EACH CUT
REPRESENT THE AVERAGE VOLUME ERROR
' CALCULATES THE LENGTH OF EACH STEP AND WRITES IT IN THE RESULTS
'FILE HEADER 
Set length1 = parameters1.Item("Tank for analysis\Analysis_References\acc_vector\End")
StepLength =2* length1.Value*StepSize
ostream.Write ("n_x; n_y; n_z; Volume; CoGx; CoGy; CoGz; Point x; Point y; Point z;
StepLength = " & StepLength & Chr(10)) ' THE HEADERS FOR THE COLUMNS
ostream.Write (" "& Chr(10))
' READS THE CSV FILE AS LONG AS THERE IS ANY LINE TO READ 
While Not Stream.AtEndOfStream
sLine = Stream.ReadLine
sWord = Split(sLine,",") 'THE TEXT LINE IS SPLIT INTO WORDS BY " , "
' STOPS THE CODE FROM ERROR IF THERE IS AN EMPTY LINE AT THE END OF
'THE INPUT FILE 
If UBound(sWord) = "1" Then
Stream.Close
ostream.Close
msgBox("The analysis was done " & now) 'TELLS THE USER WHEN THE ANALYSIS
WAS FINISHED
Exit sub
End If
' REPLACES THE DECIMAL SEPERATER "." WITH "," SO THAT CATIA KNOW IT IS
'A NUMBER AND SETS THE ORIENTATION OF THE "acc_vector" EQUAL TO THE
'INPUT 
60
X = Cstr(Replace(sWord(0), ".", " ,"))
Y = Cstr(Replace(sWord(1), ".", " ,"))
Z = Cstr(Replace(sWord(2), ".", " ,"))
realParam1.Value = X
realParam2.Value = Y
realParam3.Value = Z
' MOVES THE CUTTING PLANE IN ONE DIRECTION BY CHANGING THE RATIO
'ON THE LINE 
For j = 0.5 To 0 step  StepSize
Set Volume = parameters1.Item("inertia_fuel\Volume")
Set CoGx = parameters1.Item("inertia_fuel\Gx")
Set CoGy = parameters1.Item("inertia_fuel\Gy")
Set CoGz = parameters1.Item("inertia_fuel\Gz")
Set pointx = parameters1.Item("point_on_fuel_surface\Gx")
Set pointy = parameters1.Item("point_on_fuel_surface\Gy")
Set pointz = parameters1.Item("point_on_fuel_surface\Gz")
ratio.Value = j
On Error Resume Next 'DISABLES ALL ERRORS
part1.Update
' IF AN ERROR IS DETECTED ALL VALUES ARE SET TO NOTHING AND YOU CAN
'DECIDE WHAT TO WRITE IN THE RESULT 
If Err.Number <> 0 Then
Set Volume = Nothing
Set CoGx= Nothing
Set CoGy = Nothing
Set CoGz= Nothing
Set pointx = Nothing
Set pointy = Nothing
Set pointz = Nothing
ostream.Write ("99" & ";" & "99" & ";" & "99" & ";" & "99" & ";" & "99" & ";" & "99" &
";" & "99" & ";" & "99" & ";" & "99" & ";" & "99" & Chr(10)) 'WHAT TO WRITE IN THE
RESULT
' IF THE CENTER OF GRAVITY IS ZERO THE VOLUME IS ALSO ZERO AND WE
'HAVE MOVED OUTSIDE THE TANK AND THE FORLOOP IS ABORTED 
Elseif CoGx.Value = "0" And CoGy.Value = "0" And CoGz.Value = "0" Then
Exit For
61
' IF THE DIFFERENCE BETWEEN THE KNOWN FULL VOLUME AND THE
'CALCULATED FULL VOLUME IS SMALL THEN WE ARE AT THE EDGE OF THE
'TANK AND THE FORLOOP IS ABORTED 
Elseif (volume_ref.Value  Volume.Value) < 0.00000001 Then
Exit For
Else
' THE VALUES FROM THE MEASURES ARE CHANGED INTO A TEXT WITH A "."
'AS DELIMITER AND IS WRITEN TO THE RESULT FILE 
Volume = Cstr(Replace(Volume.Value, ",", "."))
CoGx = Cstr(Replace(CoGx.Value, ",", "."))
CoGy = Cstr(Replace(CoGy.Value, ",", "."))
CoGz = Cstr(Replace(CoGz.Value, ",", "."))
pointx = Cstr(Replace(pointx.Value, ",", "."))
pointy = Cstr(Replace(pointy.Value, ",", "."))
pointz = Cstr(Replace(pointz.Value, ",", "."))
ostream.Write (sWord(0) & ";" & sWord(1) & ";" & sWord(2) & ";" & Volume & ";" & CoGx &
";" & CoGy & ";" & CoGz & ";" & pointx & ";" & pointy & ";" & pointz & Chr(10))
End If
On Error GOTO 0 'ERRORS ARE ENABLED
Next
' IF THE NUMBER OF CUTS ARE FEW IT MEANS THAT THERE IS A BIG
'DIFFERENCE IN VOLUME BETWEEN TWO CUTS. SO THE VOLUME IS BEING CUT
'ONCE MORE, THIS TIME IN SMALLER PIECES 
If (j0.5)/(StepSize) < (1/StepSize)/4 Then
For k = 0.5 (StepSize/2) To 0 step  StepSize
Set Volume = parameters1.Item("inertia_fuel\Volume")
Set CoGx = parameters1.Item("inertia_fuel\Gx")
Set CoGy = parameters1.Item("inertia_fuel\Gy")
Set CoGz = parameters1.Item("inertia_fuel\Gz")
Set pointx = parameters1.Item("point_on_fuel_surface\Gx")
Set pointy = parameters1.Item("point_on_fuel_surface\Gy")
Set pointz = parameters1.Item("point_on_fuel_surface\Gz")
ratio.Value = k
On Error Resume Next 'DISABLES ALL ERRORS
part1.Update
62
' IF AN ERROR IS DETECTED ALL VALUES ARE SET TO NOTHING AND YOU
'CAN DECIDE WHAT TO WRITE IN THE RESULT 
If Err.Number <> 0 Then
Set Volume = Nothing
Set CoGx= Nothing
Set CoGy = Nothing
Set CoGz= Nothing
Set pointx = Nothing
Set pointy = Nothing
Set pointz = Nothing
ostream.Write ("99" & ";" & "99" & ";" & "99" & ";" & "99" & ";" & "99" & ";" & "99" &
";" & "99" & ";" & "99" & ";" & "99" & ";" & "99" & Chr(10)) 'WHAT TO WRITE IN THE
RESULT
' IF THE CENTER OF GRAVITY IS ZERO THE VOLUME IS ALSO ZERO AND
'WE HAVE MOVED OUTSIDE THE TANK AND THE FORLOOP IS ABORTED 
Elseif CoGx.Value = "0" And CoGy.Value = "0" And CoGz.Value = "0" Then
Exit For
' IF THE DIFFERENCE BETWEEN THE KNOWN FULL VOLUME AND THE
'CALCULATED FULL VOLUME IS SMALL THEN WE ARE AT THE EDGE OF THE
'TANK AND THE FORLOOP IS ABORTED 
Elseif (volume_ref.Value  Volume.Value) < 0.00000001 Then
Exit For
Else
' THE VALUES FROM THE MEASURES ARE CHANGED INTO A TEXT WITH A "."
'AS DELIMITER AND IS WRITEN TO THE RESULT FILE 
Volume = Cstr(Replace(Volume.Value, ",", "."))
CoGx = Cstr(Replace(CoGx.Value, ",", "."))
CoGy = Cstr(Replace(CoGy.Value, ",", "."))
CoGz = Cstr(Replace(CoGz.Value, ",", "."))
pointx = Cstr(Replace(pointx.Value, ",", "."))
pointy = Cstr(Replace(pointy.Value, ",", "."))
pointz = Cstr(Replace(pointz.Value, ",", "."))
ostream.Write (sWord(0) & ";" & sWord(1) & ";" & sWord(2) & ";" & Volume & ";" & CoGx &
";" & CoGy & ";" & CoGz & ";" & pointx & ";" & pointy & ";" & pointz & Chr(10))
End If
On Error GOTO 0 'ERRORS ARE ENABLED
Next
63
Else
End If
' MOVES THE CUTTING PLANE IN THE OTHER DIRECTION BY CHANGING
'THE RATIO ON THE LINE 
For i = 0.5 + StepSize To 1 step StepSize
Set Volume = parameters1.Item("inertia_fuel\Volume")
Set CoGx = parameters1.Item("inertia_fuel\Gx")
Set CoGy = parameters1.Item("inertia_fuel\Gy")
Set CoGz = parameters1.Item("inertia_fuel\Gz")
Set pointx = parameters1.Item("point_on_fuel_surface\Gx")
Set pointy = parameters1.Item("point_on_fuel_surface\Gy")
Set pointz = parameters1.Item("point_on_fuel_surface\Gz")
ratio.Value = i
On Error Resume Next 'DISABLES ALL ERRORS
part1.Update
' IF AN ERROR IS DETECTED ALL VALUES ARE SET TO NOTHING AND YOU
'CAN DECIDE WHAT TO WRITE IN THE RESULT 
If Err.Number <> 0 Then
Set Volume = Nothing
Set CoGx= Nothing
Set CoGy = Nothing
Set CoGz= Nothing
Set pointx = Nothing
Set pointy = Nothing
Set pointz = Nothing
ostream.Write ("99" & ";" & "99" & ";" & "99" & ";" & "99" & ";" & "99" & ";" &
"99" & ";" & "99" & ";" & "99" & ";" & "99" & ";" & "99" & Chr(10)) 'WHAT TO WRITE
IN THE RESULT
' IF THE CENTER OF GRAVITY IS ZERO THE VOLUME IS ALSO ZERO AND
'WE HAVE MOVED OUTSIDE THE TANK AND THE FORLOOP IS ABORTED 
Elseif CoGx.Value = "0" And CoGy.Value = "0" And CoGz.Value = "0" Then
Exit For
' IF THE DIFFERENCE BETWEEN THE KNOWN FULL VOLUME AND THE
'CALCULATED FULL VOLUME IS SMALL THEN WE ARE AT THE EDGE OF THE
'TANK AND THE FORLOOP IS ABORTED 
Elseif (volume_ref.Value  Volume.Value) < 0.00000001 Then
Exit For
64
Else
' THE VALUES FROM THE MEASURES ARE CHANGED INTO A TEXT WITH A "."
'AS DELIMITER AND IS WRITEN TO THE RESULT FILE 
Volume = Cstr(Replace(Volume.Value, ",", "."))
CoGx = Cstr(Replace(CoGx.Value, ",", "."))
CoGy = Cstr(Replace(CoGy.Value, ",", "."))
CoGz = Cstr(Replace(CoGz.Value, ",", "."))
pointx = Cstr(Replace(pointx.Value, ",", "."))
pointy = Cstr(Replace(pointy.Value, ",", "."))
pointz = Cstr(Replace(pointz.Value, ",", "."))
ostream.Write ostream.Write (sWord(0) & ";" & sWord(1) & ";" & sWord(2) & ";" & Volume &
";" & CoGx & ";" & CoGy & ";" & CoGz & ";" & pointx & ";" & pointy & ";" & pointz &
Chr(10))
End If
On Error GOTO 0 'ERRORS ARE ENABLED
Next
' IF THE NUMBER OF CUTS ARE FEW IT MEANS THAT THERE IS A BIG
'DIFFERENCE IN VOLUME BETWEEN TWO CUTS. SO THE VOLUME IS BEING CUT
'ONCE MORE, THIS TIME IN SMALLER PIECES 
If (i0.5)/(StepSize) < (1/StepSize)/4 Then
For k = 0.5 +(StepSize/2) To 1 step StepSize
Set Volume = parameters1.Item("inertia_fuel\Volume")
Set CoGx = parameters1.Item("inertia_fuel\Gx")
Set CoGy = parameters1.Item("inertia_fuel\Gy")
Set CoGz = parameters1.Item("inertia_fuel\Gz")
Set pointx = parameters1.Item("point_on_fuel_surface\Gx")
Set pointy = parameters1.Item("point_on_fuel_surface\Gy")
Set pointz = parameters1.Item("point_on_fuel_surface\Gz")
ratio.Value = k
On Error Resume Next 'DISABLES ALL ERRORS
part1.Update
' IF AN ERROR IS DETECTED ALL VALUES ARE SET TO NOTHING AND YOU
'CAN DECIDE WHAT TO WRITE IN THE RESULT 
If Err.Number <> 0 Then
Set Volume = Nothing
Set CoGx= Nothing
65
Set CoGy = Nothing
Set CoGz= Nothing
Set pointx = Nothing
Set pointy = Nothing
Set pointz = Nothing
ostream.Write ("99" & ";" & "99" & ";" & "99" & ";" & "99" & ";" & "99" & ";" &
"99" & ";" & "99" & ";" & "99" & ";" & "99" & ";" & "99" & Chr(10)) 'WHAT TO WRITE
IN THE RESULT
' IF THE CENTER OF GRAVITY IS ZERO THE VOLUME IS ALSO ZERO AND
'WE HAVE MOVED OUTSIDE THE TANK AND THE FORLOOP IS ABORTED 
Elseif CoGx.Value = "0" And CoGy.Value = "0" And CoGz.Value = "0" Then
Exit For
' IF THE DIFFERENCE BETWEEN THE KNOWN FULL VOLUME AND THE
'CALCULATED FULL VOLUME IS SMALL THEN WE ARE AT THE EDGE OF THE
'TANK AND THE FORLOOP IS ABORTED 
Elseif (volume_ref.Value  Volume.Value) < 0.00000001 Then
Exit For
Else
' THE VALUES FROM THE MEASURES ARE CHANGED INTO A TEXT WITH A "."
'AS DELIMITER AND IS WRITEN TO THE RESULT FILE 
Volume = Cstr(Replace(Volume.Value, ",", "."))
CoGx = Cstr(Replace(CoGx.Value, ",", "."))
CoGy = Cstr(Replace(CoGy.Value, ",", "."))
CoGz = Cstr(Replace(CoGz.Value, ",", "."))
pointx = Cstr(Replace(pointx.Value, ",", "."))
pointy = Cstr(Replace(pointy.Value, ",", "."))
pointz = Cstr(Replace(pointz.Value, ",", "."))
ostream.Write (sWord(0) & ";" & sWord(1) & ";" & sWord(2) & ";" & Volume & ";" & CoGx &
";" & CoGy & ";" & CoGz & ";" & pointx & ";" & pointy & ";" & pointz & Chr(10))
End If
On Error GOTO 0 'ERRORS ARE ENABLED
Next
Else
End If
wend
Stream.Close
ostream.Close
msgBox("The analysis was done " & now) 'TELLS THE USER WHEN THE ANALYSIS
WAS FINISHED
End Sub
66
Appendix 8. rbf (MATLAB function)
function [W1 X_c1] = rbf(D,PointType)
%this is the main function for the radial basis function approximation.
%D = is the result file from CATIA containing the orientation of the
%fuel acceleration vector, volumes and point coordinates
%(the file has to be imported into Matlab using fileImport Data).
%PointType = choose between PointOnSurface or CenterOfGravity depending
%on the coordinates of interest.
%the results; CenterPoints,Weights,PreScaling,OutPutScaling,MaxVolume
%is saved to a .mat file in the current directory.
switch PointType
case {'PointOnSurface'}
for i = 8:10
[W1, X_c1, k_i1, L, M] = rbf_calc(D,i);
if i == 8 % xcoordinat
CenterPointsX = X_c1;
WeightsX = W1;
PreScalingX = k_i1;
OutPutScalingX = L;
MaxVolume = M;
save PointOnSurface.mat CenterPointsX WeightsX
PreScalingX OutPutScalingX MaxVolume V4
end
if i == 9 % ycoordinat
CenterPointsY = X_c1;
WeightsY = W1;
PreScalingY = k_i1;
OutPutScalingY = L;
save PointOnSurface.mat CenterPointsY WeightsY
PreScalingY OutPutScalingY APPEND
end
if i == 10 % zcoordinat
CenterPointsZ = X_c1;
WeightsZ = W1;
PreScalingZ = k_i1;
OutPutScalingZ = L;
save PointOnSurface.mat CenterPointsZ WeightsZ
PreScalingZ OutPutScalingZ APPEND
end
end
67
case {'CenterOfGravity'}
for i = 5:7
[W1, X_c1, k_i1, L] = rbf_calc(D,i);
if i == 5 % xcoordinat
CenterPointsX = X_c1;
WeightsX = W1;
PreScalingX = k_i1;
OutPutScalingX = L;
save CenterOfGravity.mat CenterPointsX WeightsX
PreScalingX OutPutScalingX V4
end
if i == 6 % ycoordinat
CenterPointsY = X_c1;
WeightsY = W1;
PreScalingY = k_i1;
OutPutScalingY = L;
save CenterOfGravity.mat CenterPointsY WeightsY
PreScalingY OutPutScalingY APPEND
end
if i == 7 % zcoordinat
CenterPointsZ = X_c1;
WeightsZ = W1;
PreScalingZ = k_i1;
OutPutScalingZ = L;
save CenterOfGravity.mat CenterPointsZ WeightsZ
PreScalingZ OutPutScalingZ APPEND
end
end
otherwise
error('unknown PointType')
end
68
Appendix 9. rbf_calc (MATLAB function)
function [W1, X_c1, k_i1, L, M] = rbf_calc(D,i)
%prepares the data and performs the calculation for the selected point
%and its three coordinates.
I=find(D(:,4)~=99); %removes false values from the data set by sorting
out the volumes which are 99
D=D(I,:);
[N_r,N_c]=size(D);
P=D(:,i);%Which point component to calculate Px,Py,Pz,CoGx,CoGy or CoGz
P_max=max(P);
P_min=min(P);
L=(P_maxP_min);
P=P/L; %scales the vector to the length 1
M=max(D(:,4)); %Max volume
X = [D(:,1:4) P];
k_i=1*ones(N_r,1); %this is a prescaler for Gaussian RBF
% to include a constant term, first weight factor is set to zero.
%Observe that the corresponding data point might influence results as
%there will be no rbf centra at that point
k_i(1)=0;
%the average residual between the training points and the calculated
%ones are set by err. The tolerance, used for selecting centres, is
%calculated based on the err and the scale factor used for the current
%coordinate.
err = 4.1; %mm
tol = (err^2)*N_r/L^2;
[W1, X_c1, k_i1, err1] = divide_data(X(:,1:4),X(:,5),X(:,1:4),k_i,tol);
69
Appendix 10. divide_data (MATLAB function)
function [W1, X_c1, k_i1, err1]=divide_data(X,Y,Xc,k_i,tol)
%divides the data into smaller parts, which then are being trained by
%the function train_rbf. The process is influenced by the fast Fourier
%transform (FFT) algorithm.
%X = orientations of the fuel acceleration vector and the volumes
%(input)
%Y = the point component (output)
%Xc = data to be searched for centres
%k_i = prescaling for Gaussian RBF, to include a constant term
if length(X)/2<1000
[W11, X_c11,k_i11,err1]=
train_rbf(X(1:floor(end/2),:),Y(1:floor(end/2),:),Xc(1:floor(end/2),:),
k_i,'select',tol);
%picks the best points from the first half of the train data
[W12, X_c12, k_i12, err1]=
train_rbf(X(ceil(end/2):end,:),Y(ceil(end/2):end,:),Xc(ceil(end/2):end,
:),k_i,'select',tol);
%picks the best points from the second half of the train data
Xc=[X_c11;X_c12]; %the picked centre points from the two halves
W1=[W11;W12]; %the picked weights from the two halves
k_i1=[k_i11;k_i12]; %all constants
[W1, X_c1, k_i1, err1]=train_rbf(X,Y,Xc,k_i1,'select',tol);
%picks the best points from the chosen ones
else
[W11, X_c11, k_i11, err1]=
divide_data(X(1:floor(end/2),:),Y(1:floor(end/2)),Xc(1:floor(end/2),:),
k_i);%recursive call with half of the data
[W12, X_c12, k_i12, err1]=
divide_data(X(ceil(end/2):end,:),Y(ceil(end/2):end,:),Xc(ceil(end/2):en
d,:),k_i);%recursive call with the other half
Xc=[X_c11;X_c12];
W1=[W11;W12];
k_i1=[k_i11;k_i12];
[W1, X_c1, k_i1, err1]=train_rbf(X,Y,Xc,k_i1,'select',tol);
%picks the best centras and weights from all the subsets
end
70
Appendix 11. train_rbf (MATLAB function)
function [W Xc k_o err]=train_rbf(X,z,Xcin,k_i,centra,tol)
%trains a radial basis function and selects the RBF centres.
%X = matrix with training data, orientations of the fuel acceleration
%vector and the volumes.
%z = vector with output training data, the point component.
%Xcin = matrix with all possible RBF centres
%k_i = a prescaler for Gaussian RBF.
%centra may be 'preset' or 'select'. If 'preset' all points will be
%used as
%RBF centres. If 'select' then an optimized number of RBF centres will
%be selected among the data
%tol = the tolerance at which (max(abs(remaining error)) < tol) to stop
%the selection of more rbf centra. if the option centra='select' is
%chosen.
epsilon=1e15;
if strcmp(centra,'preset')
N=size(Xcin,1);%number of centres
W=zeros(N,1);%weight matrix
[xx, phi]=sim_rbf(Xcin,X,W,k_i);%simulate rbf
clear xx
W=phi\z;%find weights
Xc=Xcin;
err=(zphi*W)'*(zphi*W);
k_o=k_i;
else
M=length(z);
N=size(Xcin,1);
W=zeros(N,1);%weight matrix
[xx, P]=sim_rbf(Xcin,X,W,k_i);%simulate rbf
clear xx
znorm=z'*z;
ind=1;
errtot=eye(1,N+1);
R=eye(N);
g=zeros(N,1);
PTP=zeros(N,1);
indices=1:N;
indstop=N;
tol=tol/znorm; %this is done in order to get the tolerance equal to
the sum of squared errors obtained for the training points
71
%Modified GramSchmidt factorization of P with resorting and stopping
%criteria, see "Chen, S. et al. (1989) Orthogonal least squares methods
%and their application to nonlinear system identification",
k=1;
while (errtot(k)>tol && k<N && k<indstop)
%compute next g
for i=k:N
PTP(i)=P(:,i)'*P(:,i);
g(i)=P(:,i)'*z ./max(PTP(i),epsilon);
%compute influence on error
err(i)=g(i)^2*PTP(i)/znorm;
end
[errk,ind]=max(err(k:N));
errtot(k+1)=errtot(k)errk;
% sorting according to influence on error
ind=ind+k1;
perm=[1:k1 ind k:ind1 ind+1:N];
P=P(:,perm);
g=g(perm);
R(1:k1,:)=R(1:k1,perm);
indices=indices(perm);
% compute next row of R and next column of P
Pknorm=P(:,k)'*P(:,k);
R(k,k+1:N)=P(:,k)'*P(:,k+1:N)/max(Pknorm,epsilon);
for j=k+1:N
P(:,j)=P(:,j)R(k,j)*P(:,k);
end
%compute next z
z=zg(k)*P(:,k);
if (errtot(k+1)<tol  errk< tol/1000)
%if (max(abs(z))<tol  errk< tol/10)
indstop=k;
end
k=k+1
end
% compute last values of g(M) and errors
if indstop==N
PTP(N)=P(:,N)'*P(:,N);
g(N)=P(:,N)'*z ./max(PTP(N),epsilon);
errk=g(N)^2*PTP(N)/znorm;
errtot(N+1)=errtot(N)errk;
end
% pick out the chosen rbf centra and corresponding weights
R=R(1:indstop,1:indstop);
g=g(1:indstop);
W=R\g;
Xc=Xcin(indices(1:indstop),:);
phi=P;
err=errtot(indstop+1);
k_o=k_i(indices(1:indstop));
end
72
Appendix 12. sim_rbf (MATLAB function)
function [z phi]=sim_rbf(Xc,X,W,k_i)
%simulates a radial basis function with the Gaussian function as
%functional form.
%Xc = matrix of rbf centres
%X = matrix of the data points to simulate
%W = the weight vector
%k_i = a prescaler for the Gaussian RBF
N_r=size(Xc,1);%number of rbf centres
N_p=size(X,1);%number of data points
if numel(k_i)==1
k_i=k_i*ones(N_r);
end
phi=zeros(N_p,N_r);%rbf outputs
for i=1:N_r
if k_i(i)==0
phi(:,i)=1;
else
r=sum((repmat(Xc(i,:),N_p,1)X(:,:)).^2,2);%distance from rbf
centres to data points
phi(:,i)=exp(k_i(i).*r); %Gaussian function value
end
end
z=phi*W; % the calculated points
73
Appendix 13. Check ports (CATIA script)
' THIS SCRIPT IMPORTS THE COORDINATES TO ALL THE PORTS FROM A CSV FILE. IT THEN
„CHECKS IF THE PORTS ARE WITHIN THE TANK GEOMETRY. IF NOT, IT LET THE USER
„KNOW BY RENAMING THE PORT.
'
Sub CATMain()
Set oFileSys = CATIA.FileSystem
Set oFile = oFileSys.GetFile("H:\My Documents\CAD\Gamla indata\TEST.csv") 'THE LOCATION OF
THE CSV FILE WITH THE ORIENTATIONS OF THE ACCVECTORS
Set Stream = oFile.OpenAsTextStream("ForReading")
Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part
Set selection1 = partDocument1.Selection
Set hybridBodies1 = part1.HybridBodies
Set hybridBody1 = hybridBodies1.Add()
Set hybridShapes1 = hybridBody1.HybridShapes
Set hybridShapeFactory1 = part1.HybridShapeFactory
' START READING THE CSV FILE 
While Not Stream.AtEndOfStream 'AS LONG AS THERE IS ANY LINE TO READ
sLine = Stream.ReadLine
sWord = Split(sLine,",") 'THE TEXT LINE IS SPLIT INTO WORDS BY " , "
If UBound(sWord) = "1" Then 'STOPS THE CODE FROM ERROR IF THERE IS AN EMPTY ROW IN
THE END
Stream.Close
msgBox("It is done")
Exit sub
End If
X = Cstr(Replace(sWord(0), ".", " ,")) ' REPLACES THE DECIMAL SEPERATER " . " WITH " , "
SO THAT CATIA KNOW IT'S A NUMBER
Y = Cstr(Replace(sWord(1), ".", " ,"))
Z = Cstr(Replace(sWord(2), ".", " ,"))
' CREATES A POINT WITH THE PORT COORDINATES 
Set hybridShapePointCoord1 = hybridShapeFactory1.AddNewPointCoord(X, Y, Z)
Set axisSystems1 = part1.AxisSystems
74
Set axisSystem1 = axisSystems1.Item("Absolute Axis System")
Set reference1 = part1.CreateReferenceFromObject(axisSystem1)
hybridShapePointCoord1.RefAxisSystem = reference1
hybridBody1.AppendHybridShape hybridShapePointCoord1
part1.Update
' CREATES A SPHERE AROUND THE POINT WITH THE DIAMETER OF THE PORT 
D = 1 'DIAMETER OF THE PORT (mm)
Set reference2 = part1.CreateReferenceFromObject(hybridShapePointCoord1)
Set hybridShapeFactory1 = part1.HybridShapeFactory
Set hybridShapeSphere1 = hybridShapeFactory1.AddNewSphere(reference2, reference1, D/2, 45.000000,
45.000000, 0.000000, 180.000000)
hybridShapeSphere1.Limitation = 1
hybridBody1.AppendHybridShape hybridShapeSphere1
part1.Update
' MAKES THE SPHERE TO A SOLID BODY 
Set bodies1 = part1.Bodies
Set body1 = bodies1.Add()
part1.InWorkObject = body1
Set shapeFactory1 = part1.ShapeFactory
Set reference3 = part1.CreateReferenceFromName("")
Set closeSurface1 = shapeFactory1.AddNewCloseSurface(reference3)
Set reference4 = part1.CreateReferenceFromObject(hybridShapeSphere1)
closeSurface1.Surface = reference4
part1.Update
' CHECK IF THE SPHERE INTERSECT WITH THE TANK 
Set body2 = bodies1.Item("PartBody")
part1.InWorkObject = body2
Set shapeFactory1 = part1.ShapeFactory
Set intersect1 = shapeFactory1.AddNewIntersect(body1)
75
body1.name = "Port" + "(" + CSTR(X) + "," + CSTR(Y) + "," + CSTR(Z) + ")" ' IF THE PORT IS
WITHIN THE TANK
On Error Resume Next
part1.Update
If Err.Number <> 0 Then ' THE PORT DOES NOT INTERSECT WITH THE TANK
body1.name = "Port" + "(" + CSTR(X) + "," + CSTR(Y) + "," + CSTR(Z) + ") is outside the tank"
End if
selection1.Add intersect1
selection1.Delete
wend
Stream.Close
msgBox("It is done")
End Sub
76
Appendix 14. Max volume error (MATLAB function)
function [E M O]=max_volume_error(data)
%calculates the volume difference between all volume cuts. This
%determines the maximum error that can occur in the interpolation
%between data points
%E = maximum volume difference between two cuts
%M = mean value of all the volume differences
%O = At which orientation of the fuel acceleration vector the maximum
%volume difference is obtained.
E=[];
M=[];
O=[];
I=find(data(:,1)~=99); %removes false values from the data
data=data(I,:);
V=data(:,4);
j=1;
while j < size(V,1)
j;
i =1;
left = size(V,1)  j+1;
while sum(data(j,1:3)== data(j+i,1:3))==3
i = i+1;
if i == left
break;
end
end
Vx=V(j:j+i1,1);
Vx=sort(Vx);
for i = 2:size(Vx,1)
X(i1)=abs(Vx(i)Vx(i1));
temp_E=max(X);
temp_M=mean(X);
end
E = [E;temp_E];
M = [M;temp_M];
O = [O;data(j,1:3)];
j=j+i;
end
[Em,I]= max(E)
O(I,1:3)
Mm = mean(M)
Abstract
Engineering aircraft systems is a complex task. Therefore models and computer simulations are needed to test functions and behaviors of non existing systems, reduce testing time and cost, reduce the risk involved and to detect problems early which reduce the amount of implementation errors. At the section Vehicle Simulation and Thermal Analysis at Saab Aeronautics in Linköping every basic aircraft system is designed and simulated, for example the fuel system. Currently 2dimensional rectangular blocks are used in the simulation model to represent the fuel tanks. However, this is too simplistic to allow a more detailed analysis. The model needs to be extended with a more complex description of the tank geometry in order to get a more accurate model. This report explains the different steps in the developed methodology for combining 3dimensional geometry models of any fuel tank created in CATIA with dynamic simulation of the fuel system in Dymola. The new 3dimensional representation of the tank in Dymola should be able to calculate fuel surface location during simulation of a maneuvering aircraft. The first step of the methodology is to create a solid model of the fuel contents in the tank. Then the area of validity for the model has to be specified, in this step all possible orientations of the fuel acceleration vector within the area of validity is generated. All these orientations are used in the automated volume analysis in CATIA. For each orientation CATIA splits the fuel body in a specified number of volumes and records the volume, the location of the fuel surface and the location of the center of gravity. This recorded data is then approximated with the use of radial basis functions implemented in MATLAB. In MATLAB a surrogate model is created which are then implemented in Dymola. In this way any fuel surface location and center of gravity can be calculated in an efficient way based on the orientation of the fuel acceleration vector and the amount of fuel. The new 3dimensional tank model is simulated in Dymola and the results are compared with measures from the model in CATIA and with the results from the simulation of the old 2dimensional tank model. The results shows that the 3dimensional tank gives a better approximation of reality and that there is a big improvement compared with the 2dimensional tank model. The downside is that it takes approximately 24 hours to develop this model.
Därefter specificeras modellens giltighetsområde och alla tänkbara riktningar hos accelerationsvektorn som påverkar bränslet genereras. Nackdelen är att det tar ungefär 24 timmar att få fram denna 3dimensionella representation. bränsleytans läge samt tyngdpunktens position för varje del. För att kunna utföra mer detaljerade analyser behöver modellerna utökas med en bättre geometrisk beskrivning av bränsletankarna. Första steget i metodiken är att skapa en solid modell av bränslet som finns i tanken.
. Denna rapport går igenom de olika stegen i den framtagna metodiken för att kombinera 3. begränsa riskerna samt upptäcka problem tidigt och på så sätt minska andelen implementerade fel. ett av dessa system är bränslesystemet.dimensionella tankmodeller skapade i CATIA med dynamisk simulering av bränslesystemet i Dymola. Den nya 3dimensionella tankmodellen simuleras i Dymola och resultaten jämförs med mätningar utförda i CATIA samt med resultaten från den gamla simuleringsmodellen. Den nya 3dimensionella representationen av en tank i Dymola bör kunna beräkna bränsleytans läge under en simulering av ett manövrerande flygplan. Därför används modeller och simuleringar för att testa icke befintliga system. För varje riktning delar CATIA upp bränslemodellen i ett bestämt antal delar och registrerar volymen. På så sätt kan bränsleytans och tyngdpunktens läge beräknas på ett effektivt sätt. denna implementeras sedan i Dymola. Resultaten visar att den 3dimensionella tankmodellen ger en mycket bättre representation av verkligheten och att det är en stor förbättring jämfört med den 2dimensionella representationen. Vid sektionen Vehicle Simulation and Thermal Analysis på Saab Aeronautics i Linköping designas och simuleras varje grundflygplanssystem.Sammanfattning
Att utveckla ett nytt flygplanssystem är en väldigt komplicerad arbetsuppgift. vilket är en väldigt grov approximation. dessa används sedan i den automatiserade volymanalysen i CATIA. minska utvecklingstiden och kostnaderna. baserat på riktningen hos bränslets accelerationsvektor samt mängden bränsle i tanken. Med hjälp av radiala basfunktioner som har implementerats i MATLAB approximeras dessa data och en surrogatmodell tas fram. För närvarande används 2dimensionella rätblock i simuleringsmodellen för att representera bränsletankarna.
. supervisor at Linköping University for all the tips and all the guidance regarding the approach. CATIA and thesis writing in general. Also a thanks to Anders Darander consultant from ChargeStorm.Acknowledgment
First of all I would like to thank my supervisor at Saab. Ingela Lind for her commitment and interest. Peter Berntsson CAD support at Saab. Erik Ocholla fellow student and student reviewer and all the rest that has contributed in one way or another. She has guided and helped me to succeed with the objectives of this master thesis. I would also like to thank Mehdi Tarkian.
.
13 2 APPROACH .18 Radial Basis Functions .21 3.3.35 4.2 PROBLEM DEFINITION .15 2.2 The tank model today .12 1.35 4.10 1.3 VOLUME ANALYSIS IN CATIA .36 4.36 4.5 LIMITATIONS .19 2.6 DISPOSITION .17 2.2 DEFINE THE AREA OF VALIDITY .33 4.4 VALIDATION AGAINST MEASURED DATA .39 5.23 3.2 Data driven function approximation in MATLAB .29 3.1 DEVELOPMENT PROCESS .15 2.6 VERIFY PORT POSITIONS .1.3.2 Divergent problem solving .22 3.34 4.38 5 CONCLUSIONS.2.33 4.21 3.2 Performance .1 DATA PROCESSING .2 INVOLVED DISCIPLINES AND USED TOOLS .3 Dynamic simulation in Dymola.1.7 1.20 3 PROPOSED METHODOLOGY .1.33 4.31 4 RESULTS .4 DEVELOP A SURROGATE MODEL .39
REFERENCES .2 RESOLUTION OF THE DATA .2.2.33 4.1.7 1.1 DEVELOP A 3D MODEL OF THE FUEL .16 2.4 OBJECTIVES .17 2.1 DISCUSSION AND CONCLUSIONS .Table of Contents
1 INTRODUCTION .8 1.1 Computer Aided Design (CAD) with CATIA .3 PURPOSE .12 1.1.1 BACKGROUND .5 IMPLEMENT THE MODEL IN DYMOLA .5 SUPPORTED TANK GEOMETRIES .28 3.1 CATIA .1 Test system .15 2.3 MODEL SIMULATION IN DYMOLA .1 System Engineering .12 1.1.43
.1 Why simulate .2 MATLAB .11 1.
RBF (MATLAB FUNCTION) . RBF_CALC (MATLAB FUNCTION) .66 APPENDIX 9.68 APPENDIX 10.76
.45 APPENDIX 1.58 APPENDIX 8. HOW TO INSERT MEASURES IN CATIA .52 APPENDIX 6. DIVIDE_DATA (MATLAB FUNCTION) .APPENDIX . RUN THE ANALYSIS (CATIA SCRIPT) .69 APPENDIX 11.55 APPENDIX 7.72 APPENDIX 13.73 APPENDIX 14.46 APPENDIX 3. PREPARE THE MODEL (CATIA SCRIPT) . COPY THE SOLID INTO A NEW PART (CATIA SCRIPT) .49 APPENDIX 5.45 APPENDIX 2.70 APPENDIX 12. HOW TO ACCESS SCRIPTS IN CATIA . CHECK PORTS (CATIA SCRIPT) . TRAIN_RBF (MATLAB FUNCTION) . MAX VOLUME ERROR (MATLAB FUNCTION) . (MATLAB FUNCTION) .47 APPENDIX 4. ORIENTATION OF FUEL ACC. SIM_RBF (MATLAB FUNCTION) . PREPARE THE ANALYSIS (CATIA SCRIPT) .
When the Gripen was upgraded a major modification was made to the fuel system.
1. This can be seen in figure 1. In order to operate the aircraft the center of gravity must sit within a limited space and the fuel is a big contributor to the aircrafts center of gravity. tank models are needed to compute fuel surface location for various fuel quantities. At that point computer power was not an issue and the test rig alone would have become a bottleneck in the development. long lead times. (2009) one of the biggest challenges of fuel system design is to cope with the complex geometries of the fuel tanks.1 Background
According to Gavel (2007) the complete fuel system of the combat aircraft Saab 39 Gripen was simulated in a fullscale test rig during the initial development. In order to get a better understanding.dimensional fuel tank model is needed and why computer simulations are used. According to Langton et al. expensive tests.1 Introduction
This chapter aims to give an introduction to why a 3. Lind (2011) explains that engineering aircraft systems is a complex task due to a lot of factors. The purpose and the objectives of this master’s thesis are outlined and the chapter finishes off by giving an overview of the remaining chapters. A high interaction between systems and different engineering disciplines are needed. A decision to build a mathematical model of the system was taken. aircraft attitudes and acceleration forces. It took over 5000 hours to develop and involved seven simulation and system engineers. expensive equipment. mostly due to lack of computer power. safety constraints and varying environmental conditions. shape and placement of the fuel tanks do not only determine how far the aircraft can fly but also the stability and safety of the aircraft. The size. Gavel (2007) states that the fuel system is the largest fluid system in the aircraft and consists mostly of several tanks.
Figure 1 The tank layout of Saab 39 Gripen
7
.
central processor units (CPU) and control systems. Most of the simulations are done in Dymola using Modelica. A system is defined by Ljung and Glad (2004) as one or more objects whose behavior are to be investigated. Johannesson et al. (2004) writes that many tools used for advance modeling. This leads to one of the challenges of today‟s product development. which is an object. laboratory tests and physical prototypes is often time consuming and expensive. power . which is to manage complexity of multi technological products. (2004) states that products today are more complex and consists of many different systems such as mechanical. rescue . According to Langton et al. During a development process all these tools are often used to some extent and it is of interests to have an interaction between them. One advantage is by Brooks and Robinsons (2001) that each iteration can be repeated under the same conditions. which according to Ullman (2003) means that you need to do right from beginning.. modeling is necessary to provide valuable insight into the behavior of the highly nonlinear aspects of fuel systems and their functions. landing gear . Xialong Feng. (2004). (2004). fuel . power electric.At the section Vehicle Systems Simulation and Thermal Analysis at Saab Aeronautics in Linköping every basic aircraft system. Adam Thorp addressed during the ModProd conference in Linköping 2011 that the enhanced products and the wish to reduce cost has made a need for system simulation.
1. Then a model of the system can be used. This knowledge of the possible outcome is extremely valuable for companies as it allows an assessment of the risk involved.1 Why simulate
Johannesson et al. A lot of money and time can be saved if a problem can be discovered and corrected as soon as in the planning phase. According to Johannesson et al. which includes hydraulic. but this is not always possible. analysis and simulation are designed for one specific purpose.oriented modeling language for modeling complex physical systems. sensors.and environmental control systems is designed and tested in computer simulations. A common cause is that the system does not yet exist. (2009).1. 8
. power support . that the most important issue in product development is the time to market. a simulation model is used for testing different parameter setups and components and their effect on the system. According to Johannesson et al. A model is a simplified representation of a real system. At the same conference another important issue was raised by Dr. That is why researchers today focus on finding interfaces between the different tools so that they can be more useful and used together during the whole development process. By running a simulation on a computer the time and cost can be cut and the function and behavior of a system or product can still be predicted. Through fast iteration loops many different setups can be tested. Ullman (2003) explains that it is vital to the success of a project that the right design decisions are made during the early stages in the development process. One way of doing this is to do experiments.
The result needs to be verified through real tests. Brooks and Robinson (2001) also state that because of simplifications. Based on the results from the real tests the model can be updated to better match reality. get more effective system engineering. were load cases and configurations can be based on the results from the simulation.Brooks and Robinson (2001) also claim that simulations can be used for modeling dangerous situations. the model is not to be trusted completely. reduce the amount of implementation errors. According to Lind (2011) the ambition of using model based system engineering at Saab has various reasons. Ljung and Glad (2004) stress the importance of model validation and the knowledge of the area of validity. gain better control of model variants. These ambitions reflect very well with what the research community has mentioned as reasons for model based design. for example what happens if the fuel pump in the aircraft stops working? Simulations also provide a safe environment for training. reduce testing time and cost.
9
. to detect problems early. effectively use data from tests and also to get better secondary products. increase the ability to optimize design for different purposes. the area in which the model works. where mistakes can be made without any serious consequences. reduce project risk. such as training simulators. For example.
such as the horizon) and the size and orientation of the acceleration vector. xy or xz the calculations will be performed in and which components of the acceleration vector that will be used. Because the fuel level varies in a 2dimensional plane. The total pressures at the tank ports are crucial in order to describe the hydraulic behavior of the fuel system. It consists of different components that are linked together by relations and constrains. Kinetic and potential energy terms are neglected in energy balance and the fluid velocity inside the tank in ignored.
10
.2 The tank model today
The tank model is built in Dymola using the Modelica language. The gas pressure is also uniform and the pressure at the ports is total pressure that depends on the overall thermodynamic state in the volume and on the static head of liquid above the port. temperature and gas phase composition are set. Like in most models some assumptions are made. This means that the dimensions and the position of the tank and the ports are roughly approximated to give as good results as possible for the most common attitudes and accelerations. The basic function of the tank model is to calculate air pressure and hydrostatic pressure at connection points. fluid and port properties are defined and initial values for liquid fuel mass. Based on the amount of fuel an area in the 2dimensional plane is created and by using symmetry and given angles. Before any simulation can be performed there is a test that verifies that the ports and test probes are placed within the tank. fuel vapor and air. enthalpy and mass flow and updates the mass and energy balances in the fuel system. The fuel level is assumed to be perpendicular to the acceleration vector without any time lag.and fuel flow. The tanks are designed so that the total volume. based on air. it has to be specified in which plane. This calculation also depends on the aircraft‟s attitude (the orientation of an aircraft‟s axes relative to a reference. but can be dealt with separately. Some of them are that the tank is rectangular in three dimensions and liquid level can vary in two dimensions and remains parallel to the third. During the simulation it is possible to get an animation of how the fuel level varies in the tank. Fluid temperature is uniform and heat capacitance for the tank walls is not included. Figure 2 shows an illustration of the tank model and how the fuel is oriented by the acceleration vector. The tank has ideal phase separation between liquid fuel and gas at any time and the fluid consists of liquid fuel. gas pressure. the distance between surface and ports can be derived. When the ports positions are confirmed the function fuel level is initialized.1. This function calculates the distance from the fuel surface down to the different ports. Dynamic terms.1. The function then returns this information back to the model which calculates pressure. the unused fuel and the position of intake ports are as close to reality as possible.
The tank model has to be extended with a more detailed description of the tank geometry in order to be able to get a more accurate simulation model. so that it can be used for dynamic simulation for system design and in realtime simulators.
11
. the fuel moves around in the tank. The problem is how to use the information from these models for calculating the fuel level during dynamic simulation of a maneuvering aircraft in an efficient and correct way. This needs to be predicted by a mathematical model so that a sensor output is not interpreted as “out of fuel” just because the fuel has moved to another part of the tank.2 Problem definition
Representing fuel tanks with rectangular blocks is too simplistic to allow more detailed analysis.Figure 2 The tank model with the orientation of the acceleration g and the distance d from fuel surface to a port. Because of aircraft maneuvering and gloads. The fuel tanks contain several sensors for fuel level and a lot of intakes and venting ports. It is also of interest to know if all the inlets to the pipes that are supposed to transport the fuel are covered with fuel and what the hydrostatic pressure is at the inlet. It is very important that the engine is not fed by air as that can cause a flameout (failure to the jet engine). Likewise the sensors must indicate when the aircraft is 100% refueled to prevent overfilling.
1. A 3dimensional representation of the actual tank would help answering these questions as it would give a better insight into where the fuel is located. There are available 3dimensional models of the fuel tanks made in CATIA V5.
There are also readymade applications for function approximation to be found on the internet for MATLAB. for a given fuel state. that shows how CATIA and Dymola from Dassault Systèmes can support system development. Develop a 3dimensional tank model in Dymola that can calculate the hydrostatic pressure at an inlet during simulation of a maneuvering aircraft. MATLAB will be used for the development of a surrogate model. These applications are a good start and can be rewritten to serve the purpose of this master thesis. The calculated result should have a tolerance of around 10 liters. According to Diston et al. CATIA and Dymola. venting ports and test probes are placed within the tank geometry. also states that the fuel surface can be seen as a ripple free surface bounded by the tank walls and normal to the fuel acceleration vector. To make a technology demonstrator. the force exerted by the air.1. The aero elastic deflection will be neglected in this master thesis because of its small impact and the extra work needed to simulate it. the position of fuel inside a tank. generate realtime code and fit into the existing library. Due to previous experiences.5 Limitations
The tools used for developing this methodology are restricted to the tools used at Saab. This is an acceptable simplification under normal operating conditions but will clearly break down under any maneuvering when the fuel sloshes. The method should support a fast. Diston et al. The aero elastic deflection is the structural deformation caused by aerodynamic force. 12
.4 Objectives
The objectives of this methodology for combining 3D modeling of fuel tanks and dynamic simulation of the fuel system are as follows: To compute fuel surface location for various fuel quantities. Given that Saab has a close cooperation with Dassault Systèmes it is favorable to do as much as possible in their programs. correct and repeatable procedure so that the simulation becomes efficient. It is desirable to make the end result as close to reality as possibly but as in most models some simplifications must be made. acceleration and aero elastic deflection.
1. To construct an easy test that verifies that intakes. aircraft attitudes and acceleration forces and also the center of gravity for the fuel.


1.3 Purpose
The purpose of this master thesis is to investigate and develop a methodology for using geometry data of any fuel tank from a 3dimensional CATIA model in a dynamic simulation in Dymola. is determined by aircraft orientation.
fuel slosh takes care of giving equal levels. air is sometimes trapped in air pockets. These pockets will not be dealt with during this master thesis. Chapter 3 explains all the steps of this thesis work. The created 3dimensional tank model is simulated and the result is compared against the old tank model.
Figure 3 The assumed distribution of fuel
When the aircraft is being refueled. This is a reasonable assumption.During this work the fuel level is assumed to be perpendicular to the fuel acceleration vector without any time lag. Different aspects of the work are analyzed and potential improvements are presented.
1.6 Disposition
Chapter 2 presents some useful models which the development process has been based on. Chapter 5 contains discussion and conclusions. It is also assumed that the fuel is evenly distributed at all time.
13
. from 3D modeling in CATIA to dynamic simulation in Dymola. since there are always pipes connecting the different compartments of the tank. It is assumed that no air pockets exist. Chapter 4 presents the results from each step in aspects of both time requirements and accuracy. In other types of geometry. It also introduces the tools and what they are used for. This is shown in figure 3.
14
.
2 Approach
The development process has been based on some useful models which are presented.
2. to construct concepts and evaluate them. In this case a concept means a solution on how to use geometry data of any fuel tank from a 3dimensional CATIA model in a dynamic simulation in Dymola. These needs should be expressed in the users terminology and be as functional as possible. the concepts have been designed so that they are easy to upgrade. for example the use of radial basis functions (RBF) for surrogate modeling and parts of the CATIA scripts.1 Development process
When developing a new product it is good to have some structured method to follow.
Figure 4 The Vmodel for system engineering
The first step is to identify all the requirements. During this work the development process has been influenced by the system engineering model and most problems encountered have been solved with iterative divergent problem solving. There is also some introduction to the tools used in this master thesis and what they are used for. (2004) the philosophy of system engineering is used for developing complex system solutions.1. This has been achieved through contact with the employees at the section Vehicle Systems Simulation and Thermal Analysis at Saab Aeronautics in Linköping and thorough the master thesis proposal.1 System Engineering
According to Johannesson et al. In the system criteria step the collected needs are translated into criteria‟s which the system must fulfill. The process can be described by the so called Vmodel which can be seen in figure 4. In this master thesis these product specifications are listed as objectives in the introduction. a product specification is constructed. The next step is to develop the system architecture. can be used in other contexts and already developed solutions have been put together to serve the purpose of this master thesis.
2. In order to simplify the process of concept development. 15
.
During component testing each CATIA script and MATLAB function is tested individually to make sure it works as planned.2 Divergent problem solving
According to Johannesson et al. (2004) the process of product development can be seen as a structured problem solving where there is not just one right answer to the problem. but during this master thesis. The process is explained in figure 5.1. In the last step of the development the designed system is split into smaller components which are described in detail and designed. this was something that evolved during the work. which will work together with the other components and meet the requirements of the system (the objectives). In order to develop the best possible component. It is in this step all compromises and testing strategies are supposed to be identified.
Figure 5 Process for iterative problem solving
It starts with a problem analysis where as much background information as possible is gathered and the problem is formulated.When the system architecture is done there should be a system solution that fulfills the criteria‟s with available resources. the model of an iterative problem solving process is used. In this master thesis the design and verification of components (different CATIA scripts and MATLAB functions) and their interaction with each other can be seen as such a structured problem solving. In the next step all CATIA scripts are executed in the planed sequence and the results from CATIA are used in MATLAB to create a surrogate model which is implemented and simulated in Dymola. The right side of the Vmodel is all about verification and validation.
2. This information is then used to create a surrogate model in MATLAB which can be implemented and simulated in Dymola. The proposed methodology will be tested and evaluated by the users at Saab to see if the solution satisfies the user needs. The problem analysis should result in a requirement specification of what the product should be able to perform. in this case into different scripts and the surrogate modeling is split into different MATLAB functions. 16
. In this step errors in the interfaces and in the interaction between the modules can be detected. The last test is the user acceptance test. The system solution for this master thesis consists of extracting necessary information from the CATIA model. In system testing the developed tank model is simulated and the results are compared with the specifications to see if it meets the requirements. The different sub solutions and the interaction between the system components should be identified both with respect to technology and which way to implement them. This means that the data extraction from CATIA is split into a couple of steps.
1 Computer Aided Design (CAD) with CATIA
Based on the information from 3ds (2011a) CAD is the use of computer technology in the process of design and design documentation. CAD is used in many applications and industries.These demands will change during the process as new sub problems and solutions arise and more knowledge about the product is gained. CAD is a useful help as it lowers product development costs and shortens the design cycle. All found solutions have to be analyzed regarding properties and performance. It is mainly used for detailed engineering of 3D models and 2D drawings of physical components. then the problem has to be revised and the specifications have to be modified. The different solutions are then being compared against each other and the specifications. development of a surrogate model from the analysis results in MATLAB and finally development of a new tank model in Dymola.2.
17
. as design changes can be easily done. A lot of solutions can be generated as there are many ways to solve a problem.dimensional Interactive Application) is a software solution for product design and it supports the complete product development process. Another advantage is that the design can be parameterized and saved which enables it to be reused in other contexts. with the sensitivity analysis in mind. some for modeling and others for analysis. It can be used throughout the whole engineering process. CATIA (Computer Aided Three. When an acceptable solution has been found the process is completed but there is always the possibility to optimize further. The workbenches used in this thesis work are: Generative shape design Part design These workbenches together with the VB editor are used for creating a 3.
2. During this phase a sensitivity analysis can also be conducted. for example automotive and aerospace. It is also used to produce animations for special effects in movies.dimensional geometry model into a model that can be used in a dynamic simulation involves 3D modeling and volume analysis in CATIA. The next step is to generate solution concepts with a divergent approach. All available tools in CATIA are distributed in different workbenches.2 Involved disciplines and used tools
The process of transforming a 3. The concepts are being analyzed once more and this repeats itself until all demands are met. CATIA comes with an embedded visual basic (VB) editor which allows the user to create macros that automates the modeling.dimensional representation of the fuel in a tank and also for calculating fuel volume and fuel surface location.
2. Sometimes it is not possible to meet all the demands. from conceptual design and layout of products. If the demands are not fulfilled the concept development starts all over and the concepts are being modified or new ones are developed. in which different parameter setups and their effect on the system are investigated. through strength and dynamic analysis to definition of manufacturing methods. advertising and technical manuals.
The iterative process of modeling a surrogate model can be divided in three steps: Sample selection from the original model. The model is based on the input. data analysis and numeric computation. MATLAB contains a lot of embedded functions but there are also a lot of toolboxes available separately that provides more specialized functions. (2005).
18
. In this master thesis the surrogate modeling is about finding a continuous function that explains the nonlinear input. data visualization.
The accuracy of the surrogate model depends on the number and location of samples and also on different sources of errors. One way of making these simulations computationally cheaper is to construct approximation models. known as surrogate models. According to Queipo et al. One option is to use radial basis functions (RBF) to approximate the function.2. which together build up an overall model of the system. Surrogate models are constructed using a datadriven approach. which makes them unsuitable for routine tasks such as design optimization and sensitivity analysis as it require a lot of simulation evaluations.output behavior of the original model for some chosen data points. for example advance curve fitting. (2005) many design problems require experiments and/or simulations to evaluate how different parameters and constraints affect the results. which imitated the behavior of the original model but is less complex. Sometimes these simulations can take long time to perform because of their complexity. such as noise in the data or because of the use of an improper surrogate model. Construction of the surrogate model and optimization of the model parameters Estimation of the accuracy of the surrogate model. The results can be visualized both in 2dimensional and in 3dimensional graphs. locally linear models in different regions of the collected data. According to Queipo et al. such a function can be created by using different types of simple.2.output behavior of the fuel motion in a tank. The algorithms and the results are also easy to integrate with external applications and other programming languages.2 Data driven function approximation in MATLAB
Stated by Mathworks (2011) MATLAB is a highlevel technical language and interactive environment for algorithm development. There are different methods to accomplish this.
the orthogonal forward regression least squares algorithm is used. Billings & Luo (1989) Orthogonal least squares methods and their application to nonlinear system identification. in this master thesis the Gaussian function Φ( x xi ) = exp(k_i( x xi )2) will be used. 19
. When the training data have been approximated with a surface that provides the best fit to the training data. 1≤ i ≤ nr. (1990). the algorithm sequentially selects the centre that results in the largest reduction of the sumsquareerror between the RBF outputs and the training data. are the weights and nr the number of centres. Starting from a large data set with candidate centres. To distribute the centres in a grid may also provide an unnecessary number of centres and may not cover the input domain properly.
Figure 6 Curve fitting with Gaussian bells
According to Chen et al. Φ is a radial function. xi. are the RBF centres. In this master thesis the number of data is very large and to include all the data as centres would give a large and complex model. x xi is the Euclidean norm. The surface generated by the Gaussian function looks like a bell. the surface can then be used for interpolating. where the constant k_i controls the width of the bell.Radial Basis Functions
According to Queipo et al. Which is discussed in Chen. In order to select the most suitably centres among the data and optimize the number. When enough centres have been found to satisfy the allowed sumsquareerror the selection process is aborted. the distance between these two points. wi. By adding up a series of such bells a variety of continuous surfaces can be well approximated. In figure 6 it is shown how the Gaussian bells can be used for fitting a curve to a set of data points. The functional form of Φ can be chosen among different radial functions. The method uses linear combinations of nr radially symmetric functions placed at chosen centres to approximate a response function as
nr y ( x) Wi ( x xi )
i 1
where x Є Rn. either distributed in a grid or having one centre for each data point. the centres xi are either chosen to be a subset of the data or distributed uniformly in the input domain. 1≤ i ≤ nr. (2005) radial basis functions is used for interpolation of scattered multivariate data. The same problem exists when arbitrarily choosing a sub set of data points as centres.
A typical dynamic model consists of equations both with and without variables with derivatives. the system is called dynamic. These models are called differentialalgebraic equations models (DAE model) and have to be solved numerical during simulation.As the training data from CATIA covers the whole design space and the allowed sumsquareerror is small the training data can be well approximated. Models can be created both graphically.2. but the user is free to create their own libraries or modify the readymade to better match their needs. In order to make the calculation of the impact on the sumsquareerror for each new added centre more efficient.
20
. According to 3ds (2011b) Dymola is a tool for modeling and simulation of integrated and complex systems. the use of simple standardized components to build larger and more complex models. In a mathematical model the dynamic behavior is described by derivatives with respect to time. It makes it possible to simulate the dynamic behavior and the complex interactions between different systems. Dymola uses the open Modelica modeling language for programming. the modified GramSchmidt orthogonalization is used to form an orthogonal decomposition of the created matrix. and hydraulic and their control systems. It is in Dymola the new 3dimensional tank model will be created and simulated to better understand the dynamic movement of fuel and to calculate the hydrostatic pressure at an inlet during simulation of a maneuvering aircraft. algebraic and discrete equations.
2. thermodynamic. such as mechanical. Modelica contains a model library with standard model components.3 Dynamic simulation in Dymola
Ljung and Glad (2004) writes that a system is typically described by a number of variables that change in time. If these variables can change without any direct external influence and their value depends on its previous value. by drag and drop or through the text editor. The models are described by differential. As read on Modelica (2011) Modelica is an equation based modeling language which is based on the principals of objectoriented modeling. electrical.
Figure 7 A typical fuel tank
According to Gavel (2007) the presence of subsystems in the tank also adds up to the complexity of the model. fuel transfer.1 Develop a 3D model of the fuel
As stated by Langton et al. In order to get this specific volume a new solid has to be created. Luckily this has already been done for most of the fuel tanks at Saab. the compartment that is filled with fuel. wings are small and thin with little internal volume. A solid is the homogenous representation of an object. measurement and management. which are also represented as solid models. (2009). If this space is known the accurate volume and center of gravity for different attitudes could be obtained.
3.3 Proposed methodology
In this chapter the different steps of this thesis work will be explained. but the fuselage is also filled with equipment and weapon storage. Some of the subsystems that may be identified are engine feed. Then all different parts such as pipes and ribs. This new solid is split by the different surfaces of the aircraft‟s body. but in high speed aircraft. The fuselage is therefore used as fuel storage. In figure 7 some of the equipment can be spotted. vent and pressurizing.
21
. has to be removed. fuel is stored in wing tanks on commercial aircraft. cooling. from 3D modeling in CATIA to dynamic simulation in Dymola. The space that is of interest is that between all this equipment. So the remaining volume for fuel storage involves complex shapes as can be seen in figure 7. this is done by the Boolean operator remove in the CAD tool. What is left is a complex shaped solid which represents the volume of the fuel.and explosion protection systems. refueling.
In appendix 1 there is a MATLAB script Orientation of fuel acc. that performs these operations. To define the area of validity for the Dymola model the allowed orientations of the fuel acceleration vector has to be set. The size of this vector does not matter as it is the direction of it which is of interest.3. This is done by constraining the rotation around the three aircraft fixe axes shown in figure 8. The orientation of the fuel acceleration vector is used in the volume analysis in CATIA. The rotation around the x axis is limited by .
n s 0 0 1 0 0 1 0 cos( ) sin( ) Rx 0 sin( ) cos( ) cos( ) 0 sin( ) Ry 0 1 0 sin( ) 0 cos( ) cos( ) sin( ) 0 R z sin( ) cos( ) 0 0 0 1 n Rz Rx R y ns
(1)
(2)
(3)
22
. The orientations are changed in a specified number of steps and all possible orientations within the limits are generated. which the final Dymola model is based on. around the y axis and around the z axis. If the aircraft for example makes a right turn there will be an acceleration force acting on the fuel in the opposite direction. To achieve this a basis vector ns (1) is rotated around the three aircraft fixed axes by the basic rotation matrices (2) and the orientations of the fuel acceleration vector n (3) is obtained.2 Define the area of validity
The orientation of the fuel acceleration vector will change depending on the orientation and the acceleration of the aircraft and the gravity.
this makes the file quite big. containing the solid. When the new window is opened it will just show the coordinate system but if the model is zoomed out or if the fittoall button is clicked the tank will be visible. But due to missing workbenches. which should make it possible to insert measures through VB scripts and lack of knowledge.3 Volume analysis in CATIA
The idea is to obtain a data table of different volumes. The VB code for this operation can be found in appendix 3. All models created at Saab refer to the same coordinate system. some steps has to be done manually. This procedure will be repeated for different orientations of the fuel acceleration vector.Figure 8 The aircraft fixed coordinates
3. When the first VB script Copy the solid into a new part is executed the essential solid part body of the tank model is copied into a new part in a new file. Tank models available at Saab contain a great deal of references and surfaces that were used when the model was created. whose origin is located in front of the aircraft. such as space analysis (SPA). In appendix 2 there is a guide on how to access and use the created scripts in CATIA. in small parts and recording the data of interest. The new part is opened in a new window and it contains just one body. This is done in order to minimize the file size and make the analysis run faster.
23
. Before the script can be run the right name of the tank model has to be entered in the script. This table will be generated by splitting up a solid. see figure 9. The goal was to create and run all the operations in the analysis by the embedded visual basic (VB) editor in CATIA. the coordinates to a point on the fuel surface and the coordinates to the center of gravity for that specific volume for different orientations of the fuel acceleration vector. placed at the same coordinates as the original tank model. representing the fuel in the tank.
24
. will serve as a reference for the tank‟s center of gravity which will be used to make sure that the different orientations that are going to be tested starts from the same point. the point in center of gravity and the manually inserted measure inertia. It is on this new copy. How this is done is explained in appendix 5.
The new body. named reference. In figure 10 a screen shot from CATIA shows the two bodies in the model tree.Figure 9 The copied partbody opened in a new part in a new window. How to insert measures in CATIA. When all this is done a measure inertia must be inserted manually on the reference body. In the second VB script Prepare the model found in appendix 4 a point in the center of gravity (CoG) is created and a copy of the reference body is made. Also some measures from the bounding box and the total volume of this body are needed for constructing the next steps of this analysis. named fuel. that the analysis will be preformed.
the fuel body and the point in the center of gravity
VB script number three. By inserting measure inertia on the fuel body the volume and the coordinates for the center of gravity can be received and by inserting a regular measure on the point on the plane those coordinates can also be obtained. The result after script Prepare the analysis is shown in figure 11. Prepare the analysis in appendix 6. fuel volume. By inserting a plane orthogonal to this line and fixed at a point that is created on the line with a ratio condition between 0 and 1 (the ends of the line). The line is created from a point reference and a given length. This guarantees that the line will always go through the whole body.Figure 10 Screen shot from CATIA showing the reference body. The line represents the orientation of the fuel acceleration vector and will be changed according to all the generated orientations. which is representing the fuel surface. coordinates for a point on the fuel surface and the coordinates for the center of gravity of this fuel. creates the references needed for cutting the fuel body in smaller parts. What remains when the fuel body is cut are the representation of the amount of fuel and the location of the fuel surface in the tank at the particular orientation. The plane will move when the ratio condition is changed. This means that the point with coordinates will always be on the plane. 25
. The result from the analysis should be. The point reference is the center of gravity (CoG) created earlier and the length is set to the greatest dimension in the bounding box of the reference body. a movable cutting element is obtained. Therefore a point with coordinates is created on the moving plane with the ratio point as a reference. It creates a line and a plane that moves along this line and performs the cut.
from the center of gravity for the tank. When the cutting plane has moved outside of the body the forloop is aborted. For each step the fuel body is split and for the remaining body the volume.Figure 11 Screen shot from CATIA showing the fuel acceleration vector and the cutting plane
The last VB script Run the analysis given in appendix 7 performs the analysis. 5 and 0 with a defined number of steps. which are based on the desired volume difference between two cuts defined by the user. resulting in large difference in volume between two cuts. This is because of the fixed length of the line which the cutting plane moves along and the fixed step size for the cutting plane. So when the forloop is aborted the number of performed cuts are calculated and compared against a given minimum amount of cuts. coordinates for the point on surface and coordinates for the center of gravity are calculated and saved.
26
. The first orientation of the fuel acceleration vector is loaded and the x. The cutting plane starts from the center of the line. For some orientations of the fuel acceleration vector the number of volume cuts will be quite few. If too few cuts have been performed the cutting plane is moved once more along the line and the results are calculated for the volumes between the previous cuts. y and z components of the line created in script number three is changed according to that orientation. Also the corresponding fuel acceleration vector is saved. In the following forloop the cutting plane is moved along the line between the ratio 0. In this way it is easy to detect when the cutting plane has moved outside of the tank and no new volumes are formed. Figure 12 shows this cutting process.
because it is a basic file format that can be opened and read by most tools for example MATLAB or Dymola. shown in figure 13.
Figure 12 The analysis process when the tank is being cut between ratio 0. this enables these errors to be found and investigated. 5 and 0
Figure 13 The analysis process when the tank is being cut between ratio 0. The result is saved in a .The same procedure is repeated for the other side of the fuel body.txt file. The data in the . between ratio 0. 5 + step size and 1
27
. 5 + the step size and 1 on the line.txt file is needed to create a mathematical model that can be used during dynamic simulation. If the model should fail to create the divided body the number 99 is saved to the result file. When a sufficient amount of cuts have been performed on the body the orientation of the line is changed according to the next row in the input file and the cutting process starts all over.
Increasing that value widens the bell. This residual r in millimeters is used for calculating the tolerance tol (4). The orientation of the fuel acceleration vector. appendix 10. The RBF is usually used for approximation of a single value output. The MATLAB script can be found in appendix 8. a mathematical expression has to be found and implemented. Favorably there should be a function that gives the x. These rows correspond to errors from CATIA. The data is being saved in a format which is easy to access through Dymola. This is done through the use of radial basis functions (RBF) which has been implemented in MATLAB and Dymola. volumes and the point coordinate is then used in the function divide_data. the results. This tolerance is used for aborting the selection of centres. When the data has been loaded the function rbf is executed with this matrix as input as well as the choice of which point. It is also in rbf_calc the acceptable average residual between the training points and the calculated points are set. By stepping through all the columns containing the point coordinates and send these one by one together whit the data from CATIA as input for another function. y and z components for a point on the fuel surface. n is the number of training data. y and z component for the two points are calculated separately. volumes. together with the real constant that controls the width of the bell shape of the Gaussian function used in this RBF approximation. which is the sum of standardized squared errors for the training data. weights.
tol (r / L) 2
i 1
n
(4)
28
. because that is easiest. The data table from CATIA containing the orientations of the fuel acceleration vector. when the model failed to create a divided body. which will lead to a better approximation. so the x. The RBF approximation will be using the orientation of the fuel acceleration vector and the volume as inputs to approximate a coordinate on the fuel surface or in the center of gravity as output. The residuals are standardized with the same length L as the point coordinates. In order to be able to use the result from CATIA in a dynamic simulation in Dymola.3. pre scaling. The function rbf_calc removes all rows containing the number 99. coordinates to a point on the fuel surface and coordinates to the center of gravity for each volume is imported to MATLAB and stored as a matrix.4 Develop a surrogate model
The thesis work is about finding a way of knowing the location and orientation of the fuel surface depending on the orientation of the fuel acceleration vector and the amount of fuel left in the tank. center points. rbf_calc see appendix 9. from that the desired end results can be calculated. fuel surface or center of gravity to approximate. output scaling and max volume can be calculated for each coordinate and saved in the same file. The point coordinate to be used as output in the RBF approximation is standardizes into a vector of length one. This is done in order to balance the numerical values in the data.
5 Implement the model in Dymola
Since there is already a tank model in Dymola. When the result has been scaled the coordinate now refers to the original coordinate system used at Saab. The function train_rbf uses the function sim_rbf.Because of the large size of the matrix the calculations for finding the centres has to be split into smaller sets. After this the parameter point contains the coordinates in millimeter for a point on the fuel surface. where the sum of squared distances between all chosen centre points and the input data (the orientation of the normed acceleration vector and the current volume) is used according to (5). to calculate the output and the weights for the RBF approximation. :) x(1. from 1 to the number of RBF centres for one coordinate at the time. In the first step the Gaussian functions is calculated. otherwise MATLAB will run out of memory. which is done in two steps. the adaption to a 3. for example pressure and flow. It then makes two recursive calls with D/2 as input. The RBF surrogate model is implemented and the matrices created in MATLAB with chosen centres. weights and scaling factors are imported to the model as parameters.1) (centerPoin ts (i. D/8 and so on. The point coordinate is derived from the response surface created by the RBF approximation. In the setup for parameters it is possible to choose the right data file for the current tank.dimensional representation is just a matter of minor modifications. At this stage the obtained centres are being trained again and the most suitable centres among these are being selected and sent to the next hierarchical level. appendix 12. This distance is of interest when to calculate the pressure at the ports. The old rectangular representation and all 2 dimensional depending parameters have to be deleted. Once the points are fewer than 1000 and the data has been trained and some centres have been chosen. The gravitation and acceleration vectors have to be extended to 3 dimensions. This repeats itself until all halves has been merged and the best centres that describes the whole dataset has been chosen. these centres are sent back to the previous hierarchical level. nr (1. i) exp( preScaling (i. These calculations are done for the x. If the number of points is fewer than 1000 the data D/2 is send to the function train_rbf found in appendix 11. it makes some more recursive calls with D/4. based on the attitude of the aircraft and the given amount of fuel the model will calculate the perpendicular distance between the fuel surface and all the ports. If D/2 is greater than 1000. :)) 2 (5)
i 1
In the next step the results are multiplied with the corresponding weights (6). nr point W
i 1
(6)
The result is then scaled by the scaling factor used for standardizing in the MATLAB function rbf_calc. which calculates all the port properties that are of interest.
3. The function divide_data is inspired by the fast Fourier transform algorithm. y and z coordinate. The calculations are done in a forloop. where the centre selection is being performed based on the set tolerance. Once the simulation is going.
29
. Basically it splits the data D into two halves if the dataset is greater than 1000 points.
the numerator becomes the scalar between n and QP and the final equation is obtained n QP cos n QP . linear algebra with geometry is used. heightToLevel(i) ((( portPositi on(i.
30
.:) point ) g ) / g _ abs where g is the acceleration vector and g_abs the length of it. figure 14. If the distance is positive the port is below the fuel surface and if it is negative the port is above the fuel surface. If this equation is extended with the norm of n. By creating a vector QP between the port and the calculated point Q on the fuel surface. The port can be seen as a point P that has given coordinates and the normal n to the fuel surfaces is the acceleration vector. d d n n
Figure 14 The calculation of the distance between the fuel surface and a port
All the distances heightToLevel between ports and the fuel surface is calculated in a forloop and saved as a vector. The distance of interest is the shortest perpendicular distance between the surface and the port. the distance can be calculated with d QP cos .In order to calculate the distance between the surface and the ports.
according to figure 14. That is why one of the objectives for this master thesis is to construct a similar test for the new 3dimensional tank model. The problem is visualized in figure 15. So that different port positions can be tested in order to find the optimal placement without the risk of placing them outside the tank. By calculating the distance to these planes. the test shows that a port is within the tank geometry if the distance is positive to all planes.6 Verify port positions
In the old 2dimensional tank model there was a test that verified that the inserted ports were within the tank geometry before the simulation could be performed. in other words the planes that touch the geometry.3. One idea is based on the distance between ports and the planes that envelops the tank geometry. so this verification is crucial. This test gives a hint to if the port is within the tank but the test is weak when it comes to convex surfaces. These planes are the ones that indicate full volume for every orientation of the fuel acceleration vector. Very strange results can be received from the simulation if the ports are not placed within the tank.
Figure 15 The area in which a port can be recognized as within the tank when it is not
31
. where the dashed area represents the area in which a port can be recognized as within the tank when it is not.
If there is no intersection the port is outside of the tank and the sphere is named with its coordinates but also with “is outside the tank”.
Figure 16 Verification of port position in CATIA
32
. all coordinates to the ports are imported into CATIA and a point is created at each of these coordinates.csv file. By running the script Check ports.To be able to get a more precise verification. By making these spheres to solid bodies it is possible to check for intersections between these spheres and the tank geometry. These ports will be interpreted as within the tank by CATIA. This together with the fact that everything is visualized in CATIA makes it easy to see which ports that are okay and which that has to be moved. The coordinates to the ports should be specified in a . which in some sense represents the diameter of the inlets that the ports represents. This is shown in figure 16 where the red dots are the ports. The visualization in CATIA also makes it easy to spot the ports that are on the border of the geometry with half port within and the other half outside the tank. appendix 13. a test in CATIA is implemented instead. If there is an intersection it shows that the port is placed within the tank and the name of this sphere will be the coordinates for it. Around each point a sphere is then created.
The calculations are done on a 2. During these calculations the tolerance for selecting centres is set to a value that corresponds with a volume error of one liter between the recorded data and the calculated for each coordinate.1. If a simple tank model. After early test runs and consulting with the supervisor at Saab it was decided to let the orientation of the fuel acceleration vector change in steps of 10°. This means that within the area of validity there are 900 different orientations that are analyzed in CATIA.4 Results
In this chapter the results from each step is presented in aspects of both time requirements and accuracy. Under normal conditions/normal maneuvering it is acceptable to let the fuel acceleration vector change within ± 20° around the aircraft fixed x coordinate. then 39 hours is required and 29 588 executions are performed.1 Data processing
4. To achieve this tolerance approximately 900 basis functions is needed for the point on fuel surface and 1200 basis functions for the center of gravity. 3 MB. is analyzed in the same way it takes just three hours and 45 minutes to execute 35 676 operations.
33
. 93 GHz dual core computer with 4 GB in RAM. It does not seem to be any big difference in execution time. The file size of the detailed tank model is around 20 MB and for the simple tank 0. For example if one of the detailed tank models of around 500 liters are analyzed with an average step size of 18 liters it takes 24 hours and 19 975 executions are performed in CATIA. If the tolerance is set to decrease the volume error the time increases as more centres have to be found.
4.53 GHz dual core processor and 12 GB in RAM. But in order to keep the number of orientations at a manageable level the area of validity is restricted.2 MATLAB
When all the data from CATIA are to be trained and the RBF centres to be found. It is desirable to use as many orientations as possible in order to cover the aircraft‟s whole maneuvering area. The new 3dimensional tank model is simulated and the results are compared against the old tank model. The same tank is analyzed with an average step size of 12 liters. The computer used for the analysis has a 2. containing fewer details. 360° around the y coordinate and ± 20° around the z coordinate. the calculations done in MATLAB takes approximately 3 – 4 minutes for the point on the fuel surface and for the center of gravity around 720 minutes. based on the amount of data to be trained but rather the distribution of the data. The time requirements for performing the CATIA analysis and generate the data table is depending on how detailed the tank model is and how big the desired volume difference between two cuts are.1.
4.1 CATIA
The input to the CATIA analysis is the orientation of the fuel acceleration vector.
However this may not affect the model that much. the maximum difference between two data points from the analysis are investigated. which makes a smooth interpolation between the data points (volume cuts). it varies depending on the orientation of the acceleration vector and the shape of the tank. This means that some data are missing and the step length between two cuts are twice as far as it should be.
34
. For the analyzed tanks the average volume difference is around 18 liters. This problem also exists between the different orientations of the fuel acceleration vector. appendix 14. See figure 17. In each cut the exact volume and location of the fuel surface is recorded. This enables the user to go back to the result file from CATIA and find the reason for this difference. This is because of the fixed step length during the volume analysis. If the volume changes drastically directly after a cut the interpolated value will be way off as it presumes that the volume changes linearly to the next cut. There is also one possibility that the nearby data points from the other orientations of the fuel acceleration can make the interpolation quite accurate even for the case with the big volume difference. This interpolation may cause a difference between the actual volume and the calculated one. but between the cuts this information is not known. The geometry of the tank. It is also displayed for which orientation of the fuel acceleration vector the maximum volume difference is obtained. up to around 140 liters on a tank of 300 to 500 liters. Also some volumes could not be calculated during the analysis because of problems with reconstructing some of the surfaces on the tank model.2 Resolution of the data
The biggest approximations are made in the volume analysis in CATIA when the fuel volume is being cut.
Figure 17 The interpolation problem between two cuts
By running the MATLAB script max_volume_error. In order to get a hint of how big this miscalculation caused by the interpolation may be.4. The biggest volume difference between two cuts is quite big. which results in a big difference in volume between the cuts. by investigating the data from CATIA the case for which this maximum difference occurred can be found and avoided during simulation. depending on how irregular the fuel volume changes between the cuts. the cross section area. gives that each step represents different volumes depending on the orientation of the fuel acceleration vector. The values between the cuts are being calculated from the response surface created by RBF. the maximum volume difference between two cuts as well as the average volume difference between cuts can be seen.
a system component that specifies the acceleration and a source component with table data of the time depending orientation of the acceleration vector.
Figure 18 The test system for the new 3dimensional tank model
35
. a simple test system was designed in Dymola. The allowed residual r (mm) in the RBF approximation is calculated by dividing the acceptable volume error (1 liter) with the ratio of the average volume difference Mm (m3) and the step length L (mm).
r
1 Mm 1000 L
(7)
4. A residual equal to one liter for each coordinate is acceptable.3 Model simulation in Dymola
4. The system can be seen in figure 18. The step length between two cuts can be read in the header of the result file from CATIA and the average volume difference between two cuts is calculated using the MATLAB script max_volume_error.1 Test system
In order to test the performance and validate the results for the new 3dimensional tank model.3. The allowed residual will change depending on which tank is used. equation 7.Because of the relatively big volume difference between the data points obtained from the volume analysis in CATIA there is no need to make the RBF approximation a perfect match to the recorded data points. It consists of the tank model.
4.3. The whole fuel system was simulated with a real flight case. the time did not increase.dimensional tanks with 757. The results were also compared against the results from the old 2. The simulations are performed on a 2. The acceleration vectors used during these tests where all within the area of validity. A more realistic case was also tested. The results can be seen in table 1. was almost three times as long as with the old 2dimensional tank.dimensional tank. with different simulation times and with an acceleration vector that alters during the whole simulation.dimensional tank model in order to see how great the improvement is. based on data with a resolution of approximately 12 liters between the data points (3D.
4. When the test system was extended to include four different 3dimensional tanks.dimensional tank model was tested by simulating the distance between the fuel surface and three scattered ports and then comparing the result with measures from the actual geometry model in CATIA. 355. The used models where: The geometry model in CATIA (CAD) The 3dimensional tank model in Dymola. When the old 2. The same system with the same input but with the old 2. 1007 and 385 RBF centres were used the time increased to 30 minutes plus 10 minutes for compilation. The difference in distance was then translated into the amount of fuel it represents.2 Performance
To test the performance of the new 3dimensional tank model. using 1009 RBF centres to calculate the fuel level.dimensional tank model in Dymola (2D)
36
.18) The 3dimensional tank model in Dymola. Some of them where the same vectors used for generating the data in CATIA and some are vectors between these. a number of simulations were preformed on the test system. When the 3. 1007 and 385 RBF centres. using 757. but remained at a time comparable with just one 3dimensional tank. with maneuvering and fuel consumption.4 Validation against measured data
The accuracy of the new 3. based on data with a resolution of approximately 18 liters between the data points (3D. 93 GHz dual core computer with 4 GB in RAM The time for compilation and simulation of the new 3. 355.12) The old 2.dimensional tank model is also simulated and the difference in CPU time for simulation is compared. causing the fuel surface to move around. The system was also tested with a 3dimensional tank that used only 385 RBF centres which made the time only one third longer compared with the 2dimensional tank.dimensional tanks were used the time for simulating 450 seconds took approximately 10 minutes plus one minute for compilation.
0.78183.93969 Port (8.4.dimensional tank model did not get remarkable better when the accuracy for the centre selection in the RBF approximation was increased.0.0.0.5 81 3 5 Difference (kg) CAD2D CAD3D.14094.0. 3.0.0.18 3D.0.0.28944.12 580 577 572 420 3 8 226 227 229 142 1 3 396 408 402 324 12 6 509 505 506 538 4 3 348 338 339 420 10 9 608 605 604 411 3 4 267 266 265 308 1 2 600 594 590 429 6 10 Difference (kg) CAD2D CAD3D.095492.20074.18) is in average 3.89371.0.14094.20074.12 160 4 6 84 0 1 72 10 5 29 2 1 72 6 5 197 1 1 41 0 0.88988 0.0.0.Table 1Comparison between the results from the different models
Port (7.0.095492.0.43388.88988 0.93969 Port (8.22689.28944.93591 0.29389.11698. 3.0.95106 0. it is shown that there is a big improvement.dimensional tank model based on data with a resolution of 18 liters between the data points are almost as good as the one based on 12 liters between the data points.0.0.78183.95106 0.0.0.1 0. 0.18 CAD3D.5 34 3 5 Difference (kg) CAD2D CAD3D.0.0.89371.22689.dimensional tank (3D.12 2D CAD3D.0.0.18 CAD3D.11698.0.0.0.097535.29389.298.097535.0.1 0. It should be mentioned that the results for the 3.0.dimensional model which in average differed 42.3 2 1 160 6 5 11 1 1 198 0.095492.097535.93969 Distance between fuel surface Difference (mm) and port (mm) CAD 3D.18 3D.0.18 3D.93591 0.122.819) m Acceleration vector 0.5 171 3 5 CAD2D 72 59 59 14 61 87 20 71 CAD2D 40 24 59 7 41 58 63 38 CAD2D 18 10 59 22 11 7 89 22
This test shows that the 3. 0.3 89 81 82 71 8 7 105 107 108 116 2 3 86 88 89 112 2 3 103 108 112 69 5 9 Distance between fuel surface Difference (mm) and port (mm) CAD 3D.93591 0.43388.0.61581 0.0.0.12 2D CAD3D.095492.27) m Acceleration vector 0.18 CAD3D.18 CAD3D.20074.318.1 0.11698.32139.32139.32139.29389.0.3 2.0. 1 kg.12 98 102 107 71 4 9 99 98 96 84 1 3 55 43 49 127 12 6 18.14094.95106 0.0.29389.18 CAD3D.61581 0.
37
.0.0.dimensional tank model (3D.0.29389.0.0.28944.89371.22689.95106 0. 4.57) m Acceleration vector 0.78183.38705 0.095492.889. 0.0.29389.12 76 4 6 33 0 1 72 10 5 13 2 1 77 6 5 112 1 1 136 0 0.7 23 21 63 4. When comparing these results against the results from the old 2.12 219 223 228 295 4 9 377 376 374 410 1 3 304 292 298 376 12 6 21 25 23 34 4 2 218 227 226 295 9 8 199 201 202 311 2 3 289 289 287 425 0 2 207 213 217 288 6 10 Distance between fuel surface Difference (mm) and port (mm) CAD 3D.18 CAD3D.38705 0.12 2D CAD3D. 1 kg.38705 0.88988 0.0.95106 0.0.0.095492.61581 0. 3 kg and for the geometry model and the other 3.0.12 27 4 6 15 0 1 72 10 5 44.5 0. The difference in amount of fuel between the measures from the geometry model and the 3.12) the difference is 3.43388.95106 0.
dimensional tank models in Dymola.dimensional geometry as the shape of the tanks used at Saab varies a lot.
Figure 19 Examples of tested geometries
38
.5 Supported tank geometries
The methodology has been developed to support any kind of 3. The developed methodology has been used to create 3.4. representing some of the available tank geometries at Saab. Some of the tested geometries are shown in figure 19.
all ports can be placed at their original positions and the result is equally good for all orientations of the fuel acceleration vector. With the new 3dimensional representation it is also possible to find the best placement for fuel probes. intake and venting ports as the location of the fuel surface is better known. This means that the results from the simulation do not fully correspond to the real system but they are good enough. 39
. This in turn gives the possibility to perform more accurate pressure and flow calculations on the fuel system. One problem with the found methodology is that the analysis in CATIA takes a lot of time. The proposed methodology is one way of doing this and as the results shows the outcome is acceptable. It is possible that these restrictions are set to narrow. The result.1 Discussion and conclusions
The purpose of this master thesis was to investigate and develop a methodology for using 3dimensional CATIA models in simulations in Dymola. which has a file size of approximately 20MB after the simplification done by script Copy the model. The problem with this is not just the time but also the fact that CATIA uses all available RAM and during the analysis this memory is never released causing the computer to crash. For the tested tank geometries. In order further verify the model the results should be compared against the results from a real test flight. It is important to remember that there have been assumptions and simplifications in every step of this developed methodology. This means that the time for running the analysis on more detailed tank models in CATIA will be way too long as the detailed models can be as much as four times greater than the tested ones. the new 3dimensional tank model in Dymola is a proof that it is possible to transform CAD data into a model that can be used in a dynamic simulation. The developed methodology reduces the difficulties and the approximation errors that occur when modeling the tanks as rectangular blocks. Moreover the presented framework enables calculation of unused fuel in the tank and the possibility to better calculate the aircraft‟s center of gravity. the time for generating the data table is around 20 hours. Based on the measured result the conclusion can be drawn that the 3dimensional tanks does give a better approximation of the reality than the old 2dimensional.5 Conclusions
In this chapter different aspects of the proposed methodology are analyzed and potential improvements and areas of further development are presented. A big advantage with this methodology is that it is possible to determine how accurate the model is compared to the CAD model. This is of great help when to interpret the results from the simulation. but it seems that most test flight cases are within the area of validity. the results are only credible inside the given angles for the fuel acceleration vector. The only restriction is the area of validity. Outside of these restrictions the results cannot be trusted as the RBF has problems extrapolating the needed response surface.
5.
The existing problem with the step size also makes it hard to set the desired average volume between two cuts. As it is now. the program should restart CATIA and load it with a new batch. It would also be possible to get the desired data from a complete full and empty tank. This means that the accuracy in the model varies during a flight case. If none of the above is possible there is the option to create a program that runs the volume analysis in CATIA in batches. If a good enough approximation of the tank models could be made. investigating fewer orientations and/or volumes in order to shorten the execution time. Simply the program should start CATIA. However the best way of solving this is to use a bounding box around the tank and for each orientation the line is adjusted to fit inside this bounding box. When the first batch is done. In Dymola a BodyShape can be used to represent a body. Two more preferable ways of getting around the problem is to simplify the tank models even further and the other is to run the analysis in batches. It seems that the results always contain a larger average volume step than the set one. When that is done the model could be saved and the created “batch program” could be used. (2005). the data recording is aborted when the cutting plane has moved outside the tank. In order to make this work the first macros has to be run manually as there are manual steps in them.With more powerful computers. This could be made by some sort of wraparound technique. This bounding box method should be created so that it does not affect the execution time negatively. load a subset of orientations for the fuel acceleration vector and execute the analysis macro. With the criteria of a minimum amount of cuts for each orientation this is solved to some extent. A similar animation for the new 3dimensional tank should be of interest and it is possible to export the visualization information from CATIA by converting the CATIA model into an STL file. Then the step size could be adjusted so that each step represents equal amount of fuel. the file size and the execution time could be heavily reduced and the result would still be better than the rectangular representation. There is also a problem with the fixed step size during the volume analysis since each step represents different amount of fuel depending on the tank geometry and the orientation of the acceleration vector. As other simplifications are made in the methodology perhaps the original tank model does not need to be 100 % accurate. This body can then be represented by different available standard shapes or it can refer to CAD data for visualization. Maybe it is possible to reduce the number of executions in CATIA.
40
. In this way CATIA will execute the analysis pretty fast as it operates with a lot of available RAM memory at all time. This is discussed by Seo et al. The model verification shows that even the simulation based on fewer executions in CATIA resulted in good accuracy. This leads to the fact that the last recorded data has the value from the last cut that was within the tank. How to execute CATIA scripts in batch mode is discussed by CATIA V5 Automation (2011).dimensional tank model in Dymola there was an animation of how the fuel moved around and decreased in the tank. In the old 2. which results in a rougher model with fewer surfaces. these problems would be smaller but that is not the right action to take.
but it would have been more appropriate if everything was done in CATIA and Dymola. for example the number of executions in CATIA. by linking the result from the simulation to the tank model in CATIA. This feature is available in CATIA V6. If the animation is done in Dymola it could also be used for the verification of port positions. There is a possibility that each tank has its own optimal parameter settings as the shape of the tank differs. The objective of creating a technology demonstrator for Dassault Systèmes has been accomplished. to check if they are within the tank geometry before the simulation is performed. If this can be solved. The major questions are how big the gap between two data points from CATIA can be and how many centre points that are needed for the RBF before the accuracy of the model in Dymola becomes to poor. Perhaps it is even possible to develop a similar surrogate model which was done in MATLAB directly in Dymola. the CPU time for simulating the 3dimensional tank models could become comparable with the old 2dimensional. where Dymola is integrated into CATIA. One alternative to accomplish this is to let Dymola searches through the created data table.
41
. The reason is that the medium at that inlet changes between fuel and air constantly which causes the calculations to slow down as smaller time steps has to be taken. the shape of the Gaussian bells and the residual used when selecting centres etcetera. If all ports are represented by some sort of shape they will be visible in the animation window and it should be easy to detect if any of them by accident has been moved outside the tank. the problem with convex surfaces has to be solved and also more planes has to be created in order to encapsulate the entire tank. If the verification of port positions is to be performed mathematically by calculating the distance from the planes that encapsulate the tank and the ports.Another option is to let CATIA take care of the animation. This has to be further investigated. During the simulation on the entire fuel system it becomes very demanding for Dymola when the fuel level is stationary at an inlet. In almost every step of the proposed methodology there is a tradeoff between accuracy and execution time. the result from CATIA. It would be desirable to find the best tradeoff by experimenting with the parameters that are possible to change. This is left to be investigated by Dassault Systèmes. to find a matching value each time the orientation of the fuel acceleration vector or volume is changed in the simulation. This should work but would take longer time as the table is very big and the interpolation is done in a four dimensional space.
42
.
M MultiDisciplinary Modelling for System Integration. Elsevier. Lee. ISBN 0794303 Gavel. ComputerAided Design & Applications. 6776 Queipo N. H. J. Dresden. D (2004) Produktutveckling .effektiva metoder för konstruktion och design. S. S. R. UK Lind. Internal Journal of Control. L & Glad.R & Spicer.. Progress in Aerospace Sciences. L (2009) Aircraft Fuel Systems. ISBN 0071122818 Papers Chen. 1327 1350 Diston. T ( 2004) Modellbygge och simulering. Clark. R & Robinson. Division of Machine Design. C. Lund. Linköpings University. Preston PR4 1AX.N & Grant. Studentlitteratur. Persson. S.References
Printed Brooks. P. Hewitt. S. Kim. Goel T. Dissertation No. I & Andersson.M (1990) Practical identification of NARMAX models using radial basis functions. JG & Pettersson. Liber AB. 41.D. Y.. S ( 2001) Simulation.1067.A. Internal Journal of Control.K. Cowan. Nos. 2011 Seo.F. Shyy W. Vaidyanathan R. ISBN 9781563479632 Ljung. ISBN 9789185643042 Johannesson.G (2003) The Mechanical Design Process. 14. Y & Chae. G.. pp. 2. Haftka R. Choi. 128 43
..V. H (2011) Model Based Systems Engineering for Aircraft Systems – How does Modelica Based Tools Fit? In proceedings of the 8th International Modelica Conference. M. 52:6. D. John Wiley and Sons. pp. The McGrawHill Companies. W (1989) Orthogonal least squares methods and their application to nonlinear system identification. Department of Mechanical Engineering. Operational Research Series. Palgrave. 50:5. Inc. Billings. Song. Vol. ISBN 9147052252 Langton. M & Richards. Third Edition. Warton Aerodrome. C. K.& Tucker P. H (2007) On Aircraft Fuel Systems – Conceptual Design and Modeling. J. Billings. Ltd. S. ISBN 9144024436 Ullman.T. Vol. 1873 1896 Chen. Tookey.A & Lou. S (2005) Wraparound operation for multiresolution CAD model. BEA Systems plc. andra upplagan. (2005) Surrogatebased analysis and optimization.
2011.3ds.Electronic 3ds (2011a) Design Excellence for Product Success.org/ Viewed 6/6/2011 Verbal Feng.com/fileadmin/PRODUCTS/CATIA/PDF/CATIAbd.mathworks. Linköping 89 February.com/2010/09/26/execscriptsinbatchmode/ Viewed 29/8/2011 Mathworks (2011) Matlab. Thorp. ABB (2011) Model.3ds.html Viewed 2/6/2011 Modelica (2011) Modelica. http://www.modelica.
44
. Linköping 89 February.pdf Viewed 11/4/2011 3ds (2011b) Dymola. Presented during 5th MODPROD Workshop on ModelBased Product Development. https://www.driven Design and Optimization of Industrial Robots at ABB.wordpress. http://www. http://www. Presented during 5th MODPROD Workshop on ModelBased Product Development. Enginsoft Nordic AB (2011) Multiobjective optimization using modeFRONTIER. A. X.com/products/catia/portfolio/dymola/overview/ Viewed 2/6/2011 CATIA V5 Automation (2011) Executing CATIA scripts in batch mode. 2011.com/products/matlab/description1. http://v5vb.
for j = 1:size(theta.pi/9.pi/9.0 sin(phi(i)) cos(phi(i))].20 degrees in 5 steps(steps of 10 degrees)
Vs = [0 0 1]'.sin(theta(j)) 0 cos(theta(j))].0 0 1].sin(psi(k)) cos(psi(k)) 0.1) Rz = [cos(psi(k)) sin(psi(k)) 0. for k = 1:size(psi. %angle between x and y.pi.Appendix
Appendix 1. rotation in 3 dimensions.5)'. phi = split theta split psi = split linspace(pi/9.5)'.1) Rx = [1 0 0. end end end csvwrite('accVector. temp = [Rz*Rx*Ry*Vs]'.theta and psi for i = 1:size(phi. %starting. %rotation in 3 dimensions V = [V. Orientation of fuel acc.180 degrees in 36 steps(steps of 10 degrees) linspace(pi/9.0 cos(phi(i)) sin(phi(i)). %Based on angle changes.V) %Saves the data in the matrix V in a csv file in your working directory %The name of the file is accVector
45
.36)'. %angle between y and z. %angle between x and z.temp]. %Generates all possible combinations of phi.0 1 0.vector V = [].1) Ry = [cos(theta(j)) 0 sin(theta(j)). +/.20 degrees in 5 steps (steps of 10 degrees) = linspace(pi. +/. (MATLAB function)
%Generates a csv file with the components of the acceleration vector. +/.csv'.
46
. This is only necessary the first time you open these scripts. Click the button “Create new library” and enter the path to the right folder. To add a new library click on the “Macro libraries” button and a new dialog box opens. In order to be able to use the scripts. the folder in which they are stored must be added as a library in CATIA. The scripts will now be visible and you can run them by simply choose one of them and click “Run”.Appendix 2. How to access scripts in CATIA
The VB macros is accessible though the top menu in CATIA under Tools → Macro → Macros.
Copy the solid into a new part (CATIA script)
'THIS SCRIPT COPIES THE PARTBODY FROM THE ORIGINAL TANK MODEL INTO A 'NEW PART.CATPart") 'THE ITEM " " SHOULD BE THE NAME OF THE ORIGINAL TANK FILE specsAndGeomWindow2.CREATE A NEW PART Set documents1 = CATIA.ActiveWindow specsAndGeomWindow1.Copy
47
.Clear Set part1 = partDocument2. BY DOING THIS THE FILE SIZE 'IS HEAVILY REDUCED AND THE TIME FOR RUNING THE ANALYSIS WILL ALSO BE 'REDUCED.COPY THE PARTBODY FROM THE ORIGINAL TANK MODEL Set partDocument2 = CATIA.Selection selection1.Add body1 selection1.Part Set bodies1 = part1.WindowState = catWindowStateNormal Set windows1 = CATIA.Windows Set specsAndGeomWindow2 = windows1. Sub CATMain() '.Documents Set partDocument1 = documents1.Add("Part") Set specsAndGeomWindow1 = CATIA.ActiveDocument Set selection1 = partDocument2.Activate '.Item("PartBody") selection1. WHICH IS OPENED IN A NEW WINDOW.Bodies Set body1 = bodies1.Item("FUEL TANK 3.Appendix 3.
Part Set selection2 = partDocument1.Activate Set part2 = partDocument1.name = "reference" part2.part.Bodies.clear selection2.'.Item(i) BodyToRename.INSERT THE COPY IN THE NEW PART specsAndGeomWindow1.Update End Sub
48
.clear '.part.GetItem("Part2") product1.RENAME THE NEW PART TO "TANK FOR ANALYSIS" Set product1 = partDocument1.Selection selection2.Count Set BodyToRename = partDocument1.Bodies.PartNumber = "Tank for analysis" '.PasteSpecial("CATPrtResultWithOutLink") selection1.Add part2 selection2.RENAME THE COPIED BODY TO "REFERENCE" i = partDocument1.
HybridBodies Set hybridBody1 = hybridBodies1.CREATE GEOMETRICAL SET Set documents1 = CATIA.000000.UpdateObject hybridBody1 '.name = "CoG"
49
.CreateReferenceFromObject(coordinatepoint) Set datumpoint = hybridShapeFactory1.Add() hybridBody1. Prepare the model (CATIA script)
'THIS SCRIPT CREATES A NEW GEOMETRICAL SET IN WHICH ALL 'REFERENCES FOR THE ANALYSIS WILL BE STORED. IT ALSO CREATES A 'POINT IN THE CENTER OF GRAVITY OF THE REFERENCE BODY AND 'COPIES THE REFERENCE BODY TO A NEW BODY ON WHICH THE ANALYSIS 'WILL BE PREFORMED.AddNewPointCoord(0. 0.HybridShapeFactory Set coordinatepoint = hybridShapeFactory1.CREATE COORDINATE POINT Set hybridShapeFactory1 = part1.DeleteObjectForDatum coordpkt_ref datumpoint.Documents Set partDocument1 = CATIA.AppendHybridShape datumpoint hybridShapeFactory1.Appendix 4.name = "Analysis_References" part1.AddNewPointDatum(coordpkt_ref) arm_ref.HybridBodies.CREATE DATUM POINT "CoG" Set coordpkt_ref = part1. Sub CATMain() '.Update '.000000. 0.Part Set hybridBodies1 = part1.000000) Set arm_ref = part1.AppendHybridShape coordinatepoint part1.ActiveDocument Set part1 = partDocument1.Item("Analysis_References") arm_ref.
Selection Set selection2 = partDocument1.Clear
part1.Bodies Set body1 = bodies1.Count Set BodyToRename = partDocument1.MOVE DATUM POINT TO CENTER OF GRAVITY Set COGpointparameter = part1.Clear Set bodies1 = part1.Item("reference") selection1.CreateFormula("COG_Formula". "centerofgravity(reference)") formula1.'.name = "fuel" part1.Selection selection1.Hidden = True part1.Relations.part.Add part1 selection2.Add body1 selection1.Update '.Bodies.Parameters. COGpointparameter.COPIES REFERENCE BODY TO A NEW BODY Set selection1 = partDocument1.RENAME THE NEW BODY TO "fuel" i = partDocument1.Update
50
.Item(i) BodyToRename.Bodies.Copy selection2. "".part.PasteSpecial("CATPrtResultWithOutLink") selection2.Clear selection1.Update
'.Item("CoG") Set formula1 = part1.
'.Update msgBox("Insert a Measure Inertia on the reference body and rename it to inertia_reference") End sub
51
.HIDES THE REFERENCE BODY AND '.SetShow catvispropertynoshowattr part1.REMINDES THE USER OF INSERTING A MEASURE selection1. Add body1 Set vispropset1 = selection1.VisProperties VisPropset1.
Click the “measure inertia” button in the bottom toolbar. Choose which body you want to measure by clicking on the geometrical representation or at the name in the structure tree on the left. Both will be used and are therefore explained. center of gravity and principal axes are checked see figure 2. Make sure that volume. The measure on the reference body should be named inertia_reference and the measure on the fuel body should be named inertia_fuel .
Figure 1Measure Inertia
Figure 2 What to calculate
3. To insert measure inertia on a body: 1. 4. Make sure that “Keep measure” is checked in figure 1 and then “OK” 5. measure inertia and measure between. The measures have now appeared in the structure tree. Click on the button “Customize” and a new dialog box appears. How to insert measures in CATIA
There are two types of measures in CATIA. To change the name of it just right click on it and choose “properties”. Then the dialog box seen in figure 1appears.
52
. This step by step guide is directly applicable to the steps that are to be done manually in this master thesis. Then “OK”. 2.Appendix 5. See figure 3.
Figur 3 How to find properties
To insert a measure on the point_on_fuel_surface: 1. 2. Choose point_on_fuel_surface from the structure tree. Then the dialog box seen in figure 4 appears.
Figur 4 Measure Item
3. Make sure that “Keep measure” is checked in figure 4 and then “OK” 53
. Click the “measure between” button in the bottom toolbar.
as in figure 3. The measures have now appeared in the structure tree.4. 5. figure 5
Figur 5 Hide/Show
54
. To hide the measures from the geometrical model right click on the measure you want to hide and choose “Hide/Show”. To change the name of it just right click on it and choose “properties”.
ActiveDocument Set part1 = partDocument1.Item("Tank for analysis\inertia_reference\BBLz") 'THE ITEM " " MUST MATCH THE NAME OF THE PART lengthxy = ((lengthx.Part Set hybridBodies1 = part1.CALCULATE THE GREATEST DISTANCE IN 'THE BOUNDING BOX FOR THE TANK Set lengthx = parameters1. Prepare the analysis (CATIA script)
'THIS SCRIPT CREATES ALL LINES.value^2)^(1/2)) if lengthxy >= lengthyz And lengthxy >= lengthxz then length = lengthxy Elseif lengthyz >= lengthxy And lengthyz >= lengthxz then length = lengthyz Else length = lengthxz End if
55
. Sub CATMain() 'Set partDocument1 = CATIA. PLANES AND CUTING 'ELEMENTS THAT WILL BE USED DURING THE ANALYSIS.Appendix 6.HybridShapes Set parameters1 = part1.value^2)^(1/2)) lengthyz = ((lengthy.Item("Tank for analysis\inertia_reference\BBLy") 'THE ITEM " " MUST MATCH THE NAME OF THE PART Set lengthz = parameters1.Item("Tank for analysis\inertia_reference\BBLx") 'THE ITEM " " MUST MATCH THE NAME OF THE PART Set lengthy = parameters1.value^2 + lengthz.value^2 + lengthy.Parameters '.value^2 + lengthz. POINTS.HybridBodies Set hybridBody1 = hybridBodies1.value^2)^(1/2)) lengthxz = ((lengthx.Item("Analysis_References") Set hybridShapes1 = hybridBody1.
RefAxisSystem = reference2 Set hybridShapeLinePtDir1 = hybridShapeFactory1.CreateReferenceFromObject(axisSystem1) hybridShapeDirection1.CreateReferenceFromObject(hybridShapePointOnCurve2)
56
.AddNewLinePtDir(reference1. length/2.'. 0.Update '.Item("CoG") Set hybridShapeDirection1 = hybridShapeFactory1.Item("acc_vector") Set reference3 = part1.CREATE A PLANE. 1) Set axisSystems1 = part1.AppendHybridShape hybridShapeLinePtDir1 hybridShapeLinePtDir1.CREATE A REFERENCE POINT ON THE LINE "acc_vector" Set hybridShapeLinePtDir2 = hybridShapes1. False) hybridBody1.CreateReferenceFromObject(hybridShapeLinePtDir2) Set reference5 = part1. 0.AddNewDirectionByCoord(0.name = "acc_vector" part1.HybridShapeFactory Set hybridShapePointOnCurve1 = hybridShapes1.Item("Absolute Axis System") Set reference1 = part1.CREATE A LINE THAT IS FIXED AT CoG AND HAS A '. NORMAL TO THE LINE "acc_vector" '. length/2.CreateReferenceFromObject(hybridShapePointOnCurve1) Set reference2 = part1..CreateReferenceFromObject(hybridShapeLinePtDir2) Set hybridShapePointOnCurve2 = hybridShapeFactory1. False) hybridBody1.AppendHybridShape hybridShapePointOnCurve2 hybridShapePointOnCurve2.name = "point_reference" part1.AxisSystems Set axisSystem1 = axisSystems1.AND FIXED AT THE POINT "point_reference"Set reference4 = part1.FIXED LENGTH OF THE GREATEST DISTANCE IN THE BOUNDING BOX Set hybridShapeFactory1 = part1. hybridShapeDirection1.Update '.AddNewPointOnCurveFromPercent(reference3.0.
ShapeFactory Set reference8 = part1.CreateReferenceFromObject(hybridShapePlaneNormal1) split1. reference5) hybridBody1.CREATE A POINT ON THE FUEL SURFACE WITH X.PtRef = reference6 Set reference7 = part1.Surface = reference9 part1.Update '.000000) Set reference6 = part1.AddNewPointCoord(0. 0. name it point_on_fuel_surface ") End Sub
57
.name = "point_on_fuel_surface" part1.CreateReferenceFromName("") Set split1 = shapeFactory1. Also measure the point_on_fuel_surface.Update msgBox("Insert a Measure Inertia on fuel and rename it to inertia_fuel.RefAxisSystem = reference7 hybridBody1.SPLIT THE BODY "fuel" WITH THE CREATED PLANE '.AppendHybridShape hybridShapePointCoord1 hybridShapePointCoord1.AddNewPlaneNormal(reference4.AddNewSplit(reference8.000000.AppendHybridShape hybridShapePlaneNormal1 hybridShapePlaneNormal1.Set hybridShapePlaneNormal1 = hybridShapeFactory1.CreateReferenceFromObject(axisSystem1) hybridShapePointCoord1. 0.name = "fuel_level" part1.000000.AND REMIND THE USER TO INSERT MEASURES Set shapeFactory1 = part1.Update '. catPositiveSide) Set reference9 = part1.Z COORD Set hybridShapePointCoord1 = hybridShapeFactory1.CreateReferenceFromObject(hybridShapePointOnCurve2) hybridShapePointCoord1.Y.
csv") 'THE LOCATION OF THE CSV FILE WITH THE ORIENTATIONS OF THE ACCVECTOR Set Stream = oFile.Appendix 7. THE ITEM MUST MATCH THE NAME OF THE 'PART Set parameters1 = part1.ActiveDocument Set part1 = partDocument1.Item("fuel") Set selection1 = partDocument1.Selection selection1.Part Set bodies1 = part1.Item("Tank for analysis\Analysis_References\acc_vector\Y") Set realParam3 = parameters1.LOOP THAT 'MOVES THE CUTTING PLANE ALONG THIS LINE AND SPLITES THE BODY "fuel". THE COORDINATES 'FOR THE POINT ON THE FUEL SURFACE AND THE COORDINATES FOR THE 'CENTER OF GRAVITY IS RECORDED AND SAVED IN A TXT FILE.Item("Tank for analysis\Analysis_References\acc_vector\Z") Set ratio = parameters1.VisProperties CALCULATIONS VisPropset1. IT ALSO EXECUTES A FOR.Bodies Set body1 = bodies1.OpenAsTextStream("ForReading") Set partDocument1 = CATIA. Add body1 Set vispropset1 = selection1.GetFile("H:\My Documents\CAD\Ny indata\accVector.Item("Tank for analysis\Analysis_References\point_reference\Ratio") Set volume_ref = parameters1.THE PARAMETERS ARE SET.FileSystem Set oFile = oFileSys.Update '.SetShow catvispropertynoshowattr part1. Sub CATMain() 'Set oFileSys = CATIA.Item("Tank for analysis\Analysis_References\acc_vector\X") Set realParam2 = parameters1. 'FROM EACH CUT THE VOLUME OF THE REMANING BODY. Run the analysis (CATIA script)
'THIS SCRIPT IMPORTS COORDINATES FROM A CSV FILE AND CHANGES THE 'ORIENTATION OF THE LINE "acc_vector".Parameters Set realParam1 = parameters1.Item("Tank for analysis\inertia_reference\Volume") 'HIDES THE FUEL BODY TO SPEED UP
58
.
REPLACES THE DECIMAL SEPERATER ".AtEndOfStream sLine = Stream.READS THE CSV FILE AS LONG AS THERE IS ANY LINE TO READ While Not Stream.Value*StepSize ostream.Close msgBox("The analysis was done " & now) WAS FINISHED Exit sub End If '.FileSystem.THE NUMBER OF STEPS THAT THE LINE "acc_vector" WILL BE DEVIDEED INTO averageVolumeError = 10 'LITERS StepSize = 1/((volume_ref." WITH ".".txt". Volume.OpenAsTextStream("ForAppending") '." SO THAT CATIA KNOW IT IS 'A NUMBER AND SETS THE ORIENTATION OF THE "acc_vector" EQUAL TO THE 'INPUT 
'TELLS THE USER WHEN THE ANALYSIS
59
. "*.Write (" "& Chr(10)) '.")
'THE TEXT LINE IS SPLIT INTO WORDS BY " . CatFileSelectionModeSave) Set Datos = CATIA. CoGz.ReadLine sWord = Split(sLine. Point z.Write ("n_x. StepLength = " & StepLength & Chr(10)) ' THE HEADERS FOR THE COLUMNS ostream. CoGy. Point y.CreateFile(filename & ". n_z.value*1000)/averageVolumeError) 'MAKES EACH CUT REPRESENT THE AVERAGE VOLUME ERROR '.Close ostream.FileSelectionBox("Where do you want to save the result file". Point x. CoGx.STOPS THE CODE FROM ERROR IF THERE IS AN EMPTY LINE AT THE END OF 'THE INPUT FILE If UBound(sWord) = "1" Then Stream.'.Item("Tank for analysis\Analysis_References\acc_vector\End") StepLength =2* length1.CREATES AND OPENS THE RESULT FILE filename = CATIA. True) Set ostream = Datos. "
'.CALCULATES THE LENGTH OF EACH STEP AND WRITES IT IN THE RESULTS 'FILE HEADER Set length1 = parameters1. n_y.txt" .
")) realParam1.Number <> 0 Then Set Volume = Nothing Set CoGx= Nothing Set CoGy = Nothing Set CoGz= Nothing Set pointx = Nothing Set pointy = Nothing Set pointz = Nothing ostream.Item("inertia_fuel\Gx") Set CoGy = parameters1." & "99" & Chr(10)) 'WHAT TO WRITE IN THE RESULT '.Item("point_on_fuel_surface\Gy") Set pointz = parameters1.Item("inertia_fuel\Gy") Set CoGz = parameters1.Item("point_on_fuel_surface\Gz") ratio.IF AN ERROR IS DETECTED ALL VALUES ARE SET TO NOTHING AND YOU CAN 'DECIDE WHAT TO WRITE IN THE RESULT If Err.MOVES THE CUTTING PLANE IN ONE DIRECTION BY CHANGING THE RATIO 'ON THE LINE For j = 0. ".Value = X realParam2.Value = Z '. " .")) Z = Cstr(Replace(sWord(2)."." & "99" & "." & "99" & ".Item("inertia_fuel\Gz") Set pointx = parameters1.Value = "0" And CoGz.StepSize Set Volume = parameters1.Item("inertia_fuel\Volume") Set CoGx = parameters1." & "99" & ".".IF THE CENTER OF GRAVITY IS ZERO THE VOLUME IS ALSO ZERO AND WE 'HAVE MOVED OUTSIDE THE TANK AND THE FORLOOP IS ABORTED Elseif CoGx.Value = "0" And CoGy." & "99" & ".Update '. " . " . "." & "99" & ". ".Value = "0" Then Exit For
60
.Item("point_on_fuel_surface\Gx") Set pointy = parameters1.")) Y = Cstr(Replace(sWord(1)." & "99" & ".5 To 0 step ." & "99" & ".Value = Y realParam3.X = Cstr(Replace(sWord(0).Write ("99" & "."." & "99" & ".Value = j On Error Resume Next 'DISABLES ALL ERRORS part1.
Value.Item("point_on_fuel_surface\Gy") Set pointz = parameters1.IF THE NUMBER OF CUTS ARE FEW IT MEANS THAT THERE IS A BIG 'DIFFERENCE IN VOLUME BETWEEN TWO CUTS. ".Update
61
. "." & pointz & Chr(10)) End If On Error GOTO 0 Next
'ERRORS ARE ENABLED
'.")) ostream.Item("point_on_fuel_surface\Gx") Set pointy = parameters1.".Item("inertia_fuel\Gx") Set CoGy = parameters1.Volume.")) CoGy = Cstr(Replace(CoGy.")) CoGx = Cstr(Replace(CoGx.IF THE DIFFERENCE BETWEEN THE KNOWN FULL VOLUME AND THE 'CALCULATED FULL VOLUME IS SMALL THEN WE ARE AT THE EDGE OF THE 'TANK AND THE FORLOOP IS ABORTED Elseif (volume_ref.Item("inertia_fuel\Volume") Set CoGx = parameters1.Write (sWord(0) & "."." & sWord(2) & ".Value = k On Error Resume Next 'DISABLES ALL ERRORS part1. ". ". ".5 (StepSize/2) To 0 step .THE VALUES FROM THE MEASURES ARE CHANGED INTO A TEXT WITH A ".")) pointy = Cstr(Replace(pointy." & CoGz & ".Value. ". ".'.Value .Value. ". ".00000001 Then Exit For Else '.Item("inertia_fuel\Gz") Set pointx = parameters1." & Volume & ".Value.")) pointz = Cstr(Replace(pointz.". ".Item("inertia_fuel\Gy") Set CoGz = parameters1.Value) < 0.StepSize Set Volume = parameters1." & pointy & ". SO THE VOLUME IS BEING CUT 'ONCE MORE.Value.Value." & CoGy & ".5)/(StepSize) < (1/StepSize)/4 Then For k = 0. "." & CoGx & ".".")) CoGz = Cstr(Replace(CoGz." & sWord(1) & ".".". "." 'AS DELIMITER AND IS WRITEN TO THE RESULT FILE Volume = Cstr(Replace(Volume.".Item("point_on_fuel_surface\Gz") ratio. ". ".")) pointx = Cstr(Replace(pointx.Value." & pointx & ". THIS TIME IN SMALLER PIECES If (j0.
IF THE DIFFERENCE BETWEEN THE KNOWN FULL VOLUME AND THE 'CALCULATED FULL VOLUME IS SMALL THEN WE ARE AT THE EDGE OF THE 'TANK AND THE FORLOOP IS ABORTED Elseif (volume_ref.Write ("99" & "." & CoGx & ".Value = "0" And CoGy.")) CoGx = Cstr(Replace(CoGx." & pointz & Chr(10))
End If On Error GOTO 0 Next
'ERRORS ARE ENABLED
62
.".".00000001 Then Exit For Else '.".")) pointx = Cstr(Replace(pointx. ".IF THE CENTER OF GRAVITY IS ZERO THE VOLUME IS ALSO ZERO AND 'WE HAVE MOVED OUTSIDE THE TANK AND THE FORLOOP IS ABORTED Elseif CoGx.Value.". "." & "99" & ". ".Value." & pointx & "." & CoGz & ".Volume.")) pointz = Cstr(Replace(pointz. ". "." & CoGy & "." & "99" & ".Value .Value = "0" And CoGz.Number <> 0 Then Set Volume = Nothing Set CoGx= Nothing Set CoGy = Nothing Set CoGz= Nothing Set pointx = Nothing Set pointy = Nothing Set pointz = Nothing ostream." 'AS DELIMITER AND IS WRITEN TO THE RESULT FILE Volume = Cstr(Replace(Volume." & Volume & ".IF AN ERROR IS DETECTED ALL VALUES ARE SET TO NOTHING AND YOU 'CAN DECIDE WHAT TO WRITE IN THE RESULT If Err." & "99" & "." & "99" & ".")) pointy = Cstr(Replace(pointy.")) ostream.".Value." & "99" & ". "." & "99" & ".Value = "0" Then Exit For '. "." & "99" & ". ".")) CoGz = Cstr(Replace(CoGz.THE VALUES FROM THE MEASURES ARE CHANGED INTO A TEXT WITH A ".Value." & pointy & ".Value) < 0.Write (sWord(0) & ".'.". ".Value." & sWord(2) & ".")) CoGy = Cstr(Replace(CoGy.Value. ".Value. "." & sWord(1) & ". "." & "99" & Chr(10)) 'WHAT TO WRITE IN THE RESULT '." & "99" & ". ". ".".
Value) < 0.Number <> 0 Then Set Volume = Nothing Set CoGx= Nothing Set CoGy = Nothing Set CoGz= Nothing Set pointx = Nothing Set pointy = Nothing Set pointz = Nothing ostream.Item("point_on_fuel_surface\Gy") Set pointz = parameters1.00000001 Then Exit For
63
.Item("inertia_fuel\Gx") Set CoGy = parameters1.IF THE DIFFERENCE BETWEEN THE KNOWN FULL VOLUME AND THE 'CALCULATED FULL VOLUME IS SMALL THEN WE ARE AT THE EDGE OF THE 'TANK AND THE FORLOOP IS ABORTED Elseif (volume_ref.Item("point_on_fuel_surface\Gx") Set pointy = parameters1.Item("inertia_fuel\Gz") Set pointx = parameters1." & "99" & ".Value = "0" Then Exit For '.Value = i On Error Resume Next 'DISABLES ALL ERRORS part1.MOVES THE CUTTING PLANE IN THE OTHER DIRECTION BY CHANGING 'THE RATIO ON THE LINE For i = 0.Write ("99" & ".Volume." & "99" & ".Item("inertia_fuel\Gy") Set CoGz = parameters1.Value = "0" And CoGz.Update '." & "99" & ".Item("point_on_fuel_surface\Gz") ratio." & "99" & ".IF THE CENTER OF GRAVITY IS ZERO THE VOLUME IS ALSO ZERO AND 'WE HAVE MOVED OUTSIDE THE TANK AND THE FORLOOP IS ABORTED Elseif CoGx." & "99" & ".5 + StepSize To 1 step StepSize Set Volume = parameters1.Else End If '.Value .Value = "0" And CoGy." & "99" & "." & "99" & "." & "99" & Chr(10)) 'WHAT TO WRITE IN THE RESULT '." & "99" & ".IF AN ERROR IS DETECTED ALL VALUES ARE SET TO NOTHING AND YOU 'CAN DECIDE WHAT TO WRITE IN THE RESULT If Err.Item("inertia_fuel\Volume") Set CoGx = parameters1.
IF AN ERROR IS DETECTED ALL VALUES ARE SET TO NOTHING AND YOU 'CAN DECIDE WHAT TO WRITE IN THE RESULT If Err.".Update '.".".Item("inertia_fuel\Volume") Set CoGx = parameters1.". "." 'AS DELIMITER AND IS WRITEN TO THE RESULT FILE Volume = Cstr(Replace(Volume.5)/(StepSize) < (1/StepSize)/4 Then For k = 0.Else '. ".Write (sWord(0) & "." & CoGz & ".Item("inertia_fuel\Gx") Set CoGy = parameters1.5 +(StepSize/2) To 1 step StepSize Set Volume = parameters1. ". THIS TIME IN SMALLER PIECES If (i0.".Item("point_on_fuel_surface\Gz") ratio.Value = k On Error Resume Next 'DISABLES ALL ERRORS part1.Value.Value.Value.")) pointz = Cstr(Replace(pointz. ".")) CoGx = Cstr(Replace(CoGx." & sWord(1) & ". ".THE VALUES FROM THE MEASURES ARE CHANGED INTO A TEXT WITH A ".")) CoGz = Cstr(Replace(CoGz.Write ostream. "." & sWord(2) & "." & pointz & Chr(10)) End If On Error GOTO 0 Next
'ERRORS ARE ENABLED
'." & pointx & ". ".")) pointx = Cstr(Replace(pointx. ". ". ". SO THE VOLUME IS BEING CUT 'ONCE MORE.Item("point_on_fuel_surface\Gx") Set pointy = parameters1.Value.")) pointy = Cstr(Replace(pointy.IF THE NUMBER OF CUTS ARE FEW IT MEANS THAT THERE IS A BIG 'DIFFERENCE IN VOLUME BETWEEN TWO CUTS." & CoGy & ". ".")) CoGy = Cstr(Replace(CoGy. ". ".Number <> 0 Then Set Volume = Nothing Set CoGx= Nothing
64
.Item("inertia_fuel\Gy") Set CoGz = parameters1.Item("inertia_fuel\Gz") Set pointx = parameters1." & Volume & "." & pointy & ".Value.".")) ostream." & CoGx & ".Value.Item("point_on_fuel_surface\Gy") Set pointz = parameters1.". ".Value.
Volume.".Value = "0" And CoGy." & pointx & ".THE VALUES FROM THE MEASURES ARE CHANGED INTO A TEXT WITH A "." & "99" & ". ". "."." & pointz & Chr(10)) End If On Error GOTO 0 Next Else End If wend
'ERRORS ARE ENABLED
Stream." & CoGy & ".Close msgBox("The analysis was done " & now) WAS FINISHED End Sub
'TELLS THE USER WHEN THE ANALYSIS
65
. ".IF THE CENTER OF GRAVITY IS ZERO THE VOLUME IS ALSO ZERO AND 'WE HAVE MOVED OUTSIDE THE TANK AND THE FORLOOP IS ABORTED Elseif CoGx." & "99" & "." & pointy & "." & CoGx & ".Value. ".". ". "." & sWord(1) & ". ".Value .Value = "0" And CoGz. "." & "99" & "." & sWord(2) & ".Set CoGy = Nothing Set CoGz= Nothing Set pointx = Nothing Set pointy = Nothing Set pointz = Nothing ostream." & "99" & ".Write ("99" & ".Write (sWord(0) & ".")) pointx = Cstr(Replace(pointx.Value.".Close ostream. ".Value = "0" Then Exit For '.IF THE DIFFERENCE BETWEEN THE KNOWN FULL VOLUME AND THE 'CALCULATED FULL VOLUME IS SMALL THEN WE ARE AT THE EDGE OF THE 'TANK AND THE FORLOOP IS ABORTED Elseif (volume_ref." & CoGz & ".")) ostream. "." & "99" & Chr(10)) 'WHAT TO WRITE IN THE RESULT '.Value.Value) < 0." & "99" & ".")) CoGy = Cstr(Replace(CoGy.")) pointz = Cstr(Replace(pointz.Value." 'AS DELIMITER AND IS WRITEN TO THE RESULT FILE Volume = Cstr(Replace(Volume.")) CoGx = Cstr(Replace(CoGx.Value." & "99" & "."." & "99" & ".Value. ".".")) CoGz = Cstr(Replace(CoGz.")) pointy = Cstr(Replace(pointy. "." & "99" & ".". ".Value.00000001 Then Exit For Else '. "." & Volume & ".
%D = is the result file from CATIA containing the orientation of the %fuel acceleration vector.mat file in the current directory. save PointOnSurface. WeightsZ = W1.mat CenterPointsY WeightsY PreScalingY OutPutScalingY APPEND end if i == 10 % zcoordinat CenterPointsZ = X_c1. WeightsX = W1. MaxVolume = M. X_c1. M] = rbf_calc(D.Appendix 8.i). OutPutScalingY = L. rbf (MATLAB function)
function [W1 X_c1] = rbf(D. k_i1. OutPutScalingX = L. %PointType = choose between PointOnSurface or CenterOfGravity depending %on the coordinates of interest.PointType) %this is the main function for the radial basis function approximation. OutPutScalingZ = L. %the results. CenterPoints. PreScalingY = k_i1. PreScalingX = k_i1.MaxVolume %is saved to a .mat CenterPointsZ WeightsZ PreScalingZ OutPutScalingZ APPEND end end
66
. volumes and point coordinates %(the file has to be imported into Matlab using fileImport Data).OutPutScaling. save PointOnSurface. WeightsY = W1.Weights. save PointOnSurface.PreScaling. switch PointType case {'PointOnSurface'} for i = 8:10 [W1. if i == 8 % xcoordinat CenterPointsX = X_c1. PreScalingZ = k_i1.mat CenterPointsX WeightsX PreScalingX OutPutScalingX MaxVolume V4 end if i == 9 % ycoordinat CenterPointsY = X_c1. L.
k_i1. WeightsY = W1. X_c1. WeightsZ = W1.case {'CenterOfGravity'} for i = 5:7 [W1. OutPutScalingX = L. OutPutScalingY = L. if i == 5 % xcoordinat CenterPointsX = X_c1. save CenterOfGravity.mat CenterPointsY WeightsY PreScalingY OutPutScalingY APPEND end if i == 7 % zcoordinat CenterPointsZ = X_c1.mat CenterPointsZ WeightsZ PreScalingZ OutPutScalingZ APPEND end end otherwise error('unknown PointType') end
67
. save CenterOfGravity. PreScalingX = k_i1.i). L] = rbf_calc(D. WeightsX = W1. PreScalingZ = k_i1. save CenterOfGravity.mat CenterPointsX WeightsX PreScalingX OutPutScalingX V4 end if i == 6 % ycoordinat CenterPointsY = X_c1. PreScalingY = k_i1. OutPutScalingZ = L.
P_min=min(P). P=D(:. [N_r.5).%Which point component to calculate Px.i).i) %prepares the data and performs the calculation for the selected point %and its three coordinates. rbf_calc (MATLAB function)
function [W1.4)). The tolerance.:).1:4).X(:. is %calculated based on the err and the scale factor used for the current %coordinate. %Observe that the corresponding data point might influence results as %there will be no rbf centra at that point k_i(1)=0. %removes false values from the data set by sorting out the volumes which are 99 D=D(I. M] = rbf_calc(D. first weight factor is set to zero. L.4)~=99). err1] = divide_data(X(:. %scales the vector to the length 1 M=max(D(:. %Max volume X = [D(:.Pz. L=(P_maxP_min). used for selecting centres. I=find(D(:. err = 4.1:4) P]. X_c1. [W1.1). %mm tol = (err^2)*N_r/L^2.1:4). %the average residual between the training points and the calculated %ones are set by err. k_i1.CoGx.k_i.tol).CoGy or CoGz P_max=max(P).Py.
68
. P=P/L.Appendix 9.1. %this is a prescaler for Gaussian RBF % to include a constant term. k_i=1*ones(N_r.X(:. X_c1. k_i1.N_c]=size(D).
Xc. err1]=train_rbf(X.:).tol). divide_data (MATLAB function)
function [W1.tol).W12]. to include a constant term if length(X)/2<1000 [W11.tol). %X = orientations of the fuel acceleration vector and the volumes %(input) %Y = the point component (output) %Xc = data to be searched for centres %k_i = prescaling for Gaussian RBF. X_c11.Xc(ceil(end/2):en d.k_i1. W1=[W11. X_c11.err1]= train_rbf(X(1:floor(end/2). X_c12.'select'. [W1.Y(ceil(end/2):end.W12]. %picks the best points from the first half of the train data [W12.:).Xc. err1]= train_rbf(X(ceil(end/2):end.X_c12].k_i.k_i12]. k_i1.'select'.'select'.:).'select'. X_c1. k_i1=[k_i11.k_i). k_i12. X_c12.Appendix 10. %picks the best points from the chosen ones else [W11. %picks the best points from the second half of the train data Xc=[X_c11.%recursive call with half of the data [W12. err1]=train_rbf(X.k_i11.:). err1]= divide_data(X(1:floor(end/2).Y.k_i.tol) %divides the data into smaller parts. %the picked centre points from the two halves W1=[W11. err1]= divide_data(X(ceil(end/2):end. k_i11. k_i. %picks the best centras and weights from all the subsets end
69
. %all constants [W1.:).%recursive call with the other half Xc=[X_c11. X_c1.X_c12]. %the picked weights from the two halves k_i1=[k_i11. err1]=divide_data(X. k_i1. k_i).Y.:). X_c1.:).Y(1:floor(end/2).Y(1:floor(end/2)).k_i1.Y(ceil(end/2):end.:).tol).Xc.Xc(ceil(end/2):end.k_i12]. The process is influenced by the fast Fourier %transform (FFT) algorithm.Y. k_i12. which then are being trained by %the function train_rbf.:). :).Xc(1:floor(end/2).:).Xc(1:floor(end/2). k_i1.
the point component. %X = matrix with training data. %Xcin = matrix with all possible RBF centres %k_i = a prescaler for Gaussian RBF.X.N+1). N=size(Xcin. P]=sim_rbf(Xcin. PTP=zeros(N. ind=1.1).z. k_o=k_i. if the option centra='select' is %chosen.k_i).%simulate rbf clear xx znorm=z'*z. err=(zphi*W)'*(zphi*W).1). If 'preset' all points will be %used as %RBF centres. g=zeros(N.%find weights Xc=Xcin.1). If 'select' then an optimized number of RBF centres will %be selected among the data %tol = the tolerance at which (max(abs(remaining error)) < tol) to stop %the selection of more rbf centra. tol=tol/znorm. errtot=eye(1. %centra may be 'preset' or 'select'. W=zeros(N.'preset') N=size(Xcin. %z = vector with output training data. epsilon=1e15. if strcmp(centra. R=eye(N).%weight matrix [xx.%simulate rbf clear xx W=phi\z.1).k_i.%number of centres W=zeros(N.1).k_i).1).X. %this is done in order to get the tolerance equal to the sum of squared errors obtained for the training points
70
.%weight matrix [xx. orientations of the fuel acceleration %vector and the volumes. train_rbf (MATLAB function)
function [W Xc k_o err]=train_rbf(X.W.W.tol) %trains a radial basis function and selects the RBF centres.centra. indstop=N. indices=1:N.Xcin. phi]=sim_rbf(Xcin. else M=length(z).Appendix 11.
%Modified GramSchmidt factorization of P with resorting and stopping %criteria, see "Chen, S. et al. (1989) Orthogonal least squares methods %and their application to nonlinear system identification", k=1; while (errtot(k)>tol && k<N && k<indstop) %compute next g for i=k:N PTP(i)=P(:,i)'*P(:,i); g(i)=P(:,i)'*z ./max(PTP(i),epsilon); %compute influence on error err(i)=g(i)^2*PTP(i)/znorm; end [errk,ind]=max(err(k:N)); errtot(k+1)=errtot(k)errk; % sorting according to influence on error ind=ind+k1; perm=[1:k1 ind k:ind1 ind+1:N]; P=P(:,perm); g=g(perm); R(1:k1,:)=R(1:k1,perm); indices=indices(perm); % compute next row of R and next column of P Pknorm=P(:,k)'*P(:,k); R(k,k+1:N)=P(:,k)'*P(:,k+1:N)/max(Pknorm,epsilon); for j=k+1:N P(:,j)=P(:,j)R(k,j)*P(:,k); end %compute next z z=zg(k)*P(:,k); if (errtot(k+1)<tol  errk< tol/1000) %if (max(abs(z))<tol  errk< tol/10) indstop=k; end k=k+1 end % compute last values of g(M) and errors if indstop==N PTP(N)=P(:,N)'*P(:,N); g(N)=P(:,N)'*z ./max(PTP(N),epsilon); errk=g(N)^2*PTP(N)/znorm; errtot(N+1)=errtot(N)errk; end % pick out the chosen rbf centra and corresponding weights R=R(1:indstop,1:indstop); g=g(1:indstop); W=R\g; Xc=Xcin(indices(1:indstop),:); phi=P; err=errtot(indstop+1); k_o=k_i(indices(1:indstop)); end
71
Appendix 12. sim_rbf (MATLAB function)
function [z phi]=sim_rbf(Xc,X,W,k_i) %simulates a radial basis function with the Gaussian function as %functional form. %Xc = matrix of rbf centres %X = matrix of the data points to simulate %W = the weight vector %k_i = a prescaler for the Gaussian RBF N_r=size(Xc,1);%number of rbf centres N_p=size(X,1);%number of data points if numel(k_i)==1 k_i=k_i*ones(N_r); end phi=zeros(N_p,N_r);%rbf outputs for i=1:N_r if k_i(i)==0 phi(:,i)=1; else r=sum((repmat(Xc(i,:),N_p,1)X(:,:)).^2,2);%distance from rbf centres to data points phi(:,i)=exp(k_i(i).*r); %Gaussian function value end end z=phi*W; % the calculated points
72
Appendix 13. Check ports (CATIA script)
' THIS SCRIPT IMPORTS THE COORDINATES TO ALL THE PORTS FROM A CSV FILE. IT THEN „CHECKS IF THE PORTS ARE WITHIN THE TANK GEOMETRY. IF NOT, IT LET THE USER „KNOW BY RENAMING THE PORT. 'Sub CATMain() Set oFileSys = CATIA.FileSystem Set oFile = oFileSys.GetFile("H:\My Documents\CAD\Gamla indata\TEST.csv") 'THE LOCATION OF THE CSV FILE WITH THE ORIENTATIONS OF THE ACCVECTORS Set Stream = oFile.OpenAsTextStream("ForReading") Set partDocument1 = CATIA.ActiveDocument Set part1 = partDocument1.Part Set selection1 = partDocument1.Selection Set hybridBodies1 = part1.HybridBodies Set hybridBody1 = hybridBodies1.Add() Set hybridShapes1 = hybridBody1.HybridShapes Set hybridShapeFactory1 = part1.HybridShapeFactory ' START READING THE CSV FILE While Not Stream.AtEndOfStream 'AS LONG AS THERE IS ANY LINE TO READ sLine = Stream.ReadLine sWord = Split(sLine,",") 'THE TEXT LINE IS SPLIT INTO WORDS BY " , " If UBound(sWord) = "1" Then 'STOPS THE CODE FROM ERROR IF THERE IS AN EMPTY ROW IN THE END Stream.Close msgBox("It is done") Exit sub End If X = Cstr(Replace(sWord(0), ".", " ,")) ' REPLACES THE DECIMAL SEPERATER " . " WITH " , " SO THAT CATIA KNOW IT'S A NUMBER Y = Cstr(Replace(sWord(1), ".", " ,")) Z = Cstr(Replace(sWord(2), ".", " ,")) ' CREATES A POINT WITH THE PORT COORDINATES Set hybridShapePointCoord1 = hybridShapeFactory1.AddNewPointCoord(X, Y, Z) Set axisSystems1 = part1.AxisSystems
73
AddNewSphere(reference2.Limitation = 1 hybridBody1.ShapeFactory Set reference3 = part1.CreateReferenceFromObject(hybridShapeSphere1) closeSurface1.MAKES THE SPHERE TO A SOLID BODY Set bodies1 = part1.000000. 45.AddNewIntersect(body1)
74
.AddNewCloseSurface(reference3) Set reference4 = part1.Item("PartBody") part1.CreateReferenceFromObject(axisSystem1) hybridShapePointCoord1.CREATES A SPHERE AROUND THE POINT WITH THE DIAMETER OF THE PORT D = 1 'DIAMETER OF THE PORT (mm) Set reference2 = part1.Item("Absolute Axis System") Set reference1 = part1.Update '.000000. 45.Update '.CreateReferenceFromName("") Set closeSurface1 = shapeFactory1.AppendHybridShape hybridShapeSphere1 part1.Surface = reference4 part1.HybridShapeFactory Set hybridShapeSphere1 = hybridShapeFactory1.000000. D/2.CreateReferenceFromObject(hybridShapePointCoord1) Set hybridShapeFactory1 = part1.ShapeFactory Set intersect1 = shapeFactory1. 180.RefAxisSystem = reference1 hybridBody1.000000) hybridShapeSphere1.Update '.AppendHybridShape hybridShapePointCoord1 part1.Set axisSystem1 = axisSystems1. 0. reference1.Bodies Set body1 = bodies1.Add() part1.CHECK IF THE SPHERE INTERSECT WITH THE TANK Set body2 = bodies1.InWorkObject = body2 Set shapeFactory1 = part1.InWorkObject = body1 Set shapeFactory1 = part1.
" + CSTR(Y) + "." + CSTR(Z) + ")" ' IF THE PORT IS WITHIN THE TANK On Error Resume Next part1." + CSTR(Z) + ") is outside the tank" End if selection1." + CSTR(Y) + ".Add intersect1 selection1.Delete wend Stream.body1.name = "Port" + "(" + CSTR(X) + ".Update If Err.name = "Port" + "(" + CSTR(X) + ".Number <> 0 Then ' THE PORT DOES NOT INTERSECT WITH THE TANK body1.Close msgBox("It is done") End Sub
75
.
while j < size(V.4).1) X(i1)=abs(Vx(i)Vx(i1)).1:3)== data(j+i. for i = 2:size(Vx. end E = [E.1) .j+1.1). M=[].1:3)]. j=j+i. V=data(:.1:3) Mm = mean(M)
76
. end end Vx=V(j:j+i1. Max volume error (MATLAB function)
function [E M O]=max_volume_error(data) %calculates the volume difference between all volume cuts. I=find(data(:. while sum(data(j.Appendix 14.temp_M]. left = size(V. temp_E=max(X).1:3))==3 i = i+1. i =1. j=1. end [Em. This %determines the maximum error that can occur in the interpolation %between data points %E = maximum volume difference between two cuts %M = mean value of all the volume differences %O = At which orientation of the fuel acceleration vector the maximum %volume difference is obtained. O = [O.I]= max(E) O(I. E=[].:).1)~=99). temp_M=mean(X).temp_E].1) j. %removes false values from the data data=data(I. O=[]. M = [M. Vx=sort(Vx). if i == left break.data(j.