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
LIU-IEI-TEK-A--11/01201--SE

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 2-dimensional 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 3-dimensional 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 3-dimensional 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 2-dimensional tank model. The results shows that the 3-dimensional 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 3-dimensionella 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 3-dimensionella 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 3-dimensionella 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 3-dimensionella 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 full-scale 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 lay-out 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 non-linear 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 2-dimensional 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 g-loads, 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 3-dimensional 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 3-dimensional 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 real-time 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 3-dimensional 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 3-dimensional tank model in Dymola that can calculate the hydrostatic
pressure at an inlet during simulation of a maneuvering aircraft, generate real-time
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 3-dimensional 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 V-model 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 3-dimensional
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 V-model 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 high-level 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 2-dimensional 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 data-driven
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 non-linear 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 sum-square-error between the RBF outputs and the training data.
When enough centres have been found to satisfy the allowed sum-square-error 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-
square-error is small the training data can be well approximated. In order to make the
calculation of the impact on the sum-square-error for each new added centre more
efficient, the modified Gram-Schmidt 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 differential-algebraic 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 object-oriented 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 3-dimensional 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 fit-to-all 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 for-loop 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 for-loop 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 for-loop 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 2-dimensional 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 3-dimensional 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 3-dimensional 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 7-20 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 3-dimensional 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 3-dimensional tank model
36

4.3.2 Performance
To test the performance of the new 3-dimensional 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 3-dimensional 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 3-dimensional 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 3-dimensional tank model in Dymola, based on data with a resolution of
approximately 18 liters between the data points (3D.18)

 The 3-dimensional 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 CAD-3D.18 CAD-3D.12 CAD-2D CAD-3D.18 CAD-3D.12 CAD-2D
-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 CAD-3D.18 CAD-3D.12 CAD-2D CAD-3D.18 CAD-3D.12 CAD-2D
-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 CAD-3D.18 CAD-3D.12 CAD-2D CAD-3D.18 CAD-3D.12 CAD-2D
-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
3-dimensional 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 3-dimensional tanks
does give a better approximation of the reality than the old 2-dimensional. 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 wrap-around 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 3-dimensional
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
3-dimensional tank models could become comparable with the old 2-dimensional.

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 0-79430-3

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 978-91-85643-04-2

Johannesson. H, Persson. J-G & Pettersson. D (2004) Produktutveckling - effektiva
metoder för konstruktion och design. Liber AB. ISBN 91-47-05225-2

Langton. R, Clark. C, Hewitt. M & Richards. L (2009) Aircraft Fuel Systems. John Wiley
and Sons, Ltd. ISBN 978-1-56347-963-2

Ljung. L & Glad. T ( 2004) Modellbygge och simulering. Studentlitteratur, Lund, andra
upplagan. ISBN 91-44-02443-6

Ullman. D.G (2003) The Mechanical Design Process, Third Edition. The McGraw-Hill
Companies, Inc. ISBN 0-07-112281-8

Papers
Chen. S, Billings. S.A & Lou. W (1989) Orthogonal least squares methods and their
application to non-linear 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 Multi-Disciplinary 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) Wrap-around operation for
multi-resolution CAD model, Computer-Aided Design & Applications, Vol. 2, Nos. 1-4,
pp. 67-76

Queipo N.V., Haftka R.T., Shyy W., Goel T., Vaidyanathan R.& Tucker P.K. (2005)
Surrogate-based analysis and optimization. Progress in Aerospace Sciences, Vol. 41,
Elsevier, pp. 1-28
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/exec-scripts-in-batch-mode/
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 Model-Based Product
Development. Linköping 8-9 February, 2011.

Thorp. A, Enginsoft Nordic AB (2011) Multi-objective optimization using
modeFRONTIER. Presented during 5th MODPROD Workshop on Model-Based Product
Development. Linköping 8-9 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 ACC-VECTOR

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 FOR-LOOP 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 FOR-LOOP 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 (j-0.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 FOR-LOOP 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 FOR-LOOP 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 FOR-LOOP 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 FOR-LOOP 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 (i-0.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 FOR-LOOP 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 FOR-LOOP 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 file-Import 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 % x-coordinat
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 % y-coordinat
CenterPointsY = X_c1;
WeightsY = W1;
PreScalingY = k_i1;
OutPutScalingY = L;

save PointOnSurface.mat CenterPointsY WeightsY
PreScalingY OutPutScalingY -APPEND
end

if i == 10 % z-coordinat
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 % x-coordinat
CenterPointsX = X_c1;
WeightsX = W1;
PreScalingX = k_i1;
OutPutScalingX = L;

save CenterOfGravity.mat CenterPointsX WeightsX
PreScalingX OutPutScalingX -V4
end

if i == 6 % y-coordinat
CenterPointsY = X_c1;
WeightsY = W1;
PreScalingY = k_i1;
OutPutScalingY = L;

save CenterOfGravity.mat CenterPointsY WeightsY
PreScalingY OutPutScalingY -APPEND
end

if i == 7 % z-coordinat
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_max-P_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=1e-15;
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=(z-phi*W)'*(z-phi*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 Gram-Schmidt factorization of P with resorting and stopping
%criteria, see "Chen, S. et al. (1989) Orthogonal least squares methods
%and their application to non-linear 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+k-1;
perm=[1:k-1 ind k:ind-1 ind+1:N];
P=P(:,perm);
g=g(perm);
R(1:k-1,:)=R(1:k-1,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=z-g(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 ACC-VECTORS

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+i-1,1);
Vx=sort(Vx);

for i = 2:size(Vx,1)
X(i-1)=abs(Vx(i)-Vx(i-1));
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 2-dimensional 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 3-dimensional 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 3-dimensional 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 2-dimensional tank model. The results shows that the 3-dimensional 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.

Den nya 3-dimensionella representationen av en tank i Dymola bör kunna beräkna bränsleytans läge under en simulering av ett manövrerande flygplan.Sammanfattning Att utveckla ett nytt flygplanssystem är en väldigt komplicerad arbetsuppgift. På så sätt kan bränsleytans och tyngdpunktens läge beräknas på ett effektivt sätt. Med hjälp av radiala basfunktioner som har implementerats i MATLAB approximeras dessa data och en surrogatmodell tas fram. För varje riktning delar CATIA upp bränslemodellen i ett bestämt antal delar och registrerar volymen. Därför används modeller och simuleringar för att testa icke befintliga system.dimensionella tankmodeller skapade i CATIA med dynamisk simulering av bränslesystemet i Dymola. vilket är en väldigt grov approximation. Första steget i metodiken är att skapa en solid modell av bränslet som finns i tanken. Vid sektionen Vehicle Simulation and Thermal Analysis på Saab Aeronautics i Linköping designas och simuleras varje grundflygplanssystem. . begränsa riskerna samt upptäcka problem tidigt och på så sätt minska andelen implementerade fel. bränsleytans läge samt tyngdpunktens position för varje del. denna implementeras sedan i Dymola. Resultaten visar att den 3-dimensionella 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. minska utvecklingstiden och kostnaderna. baserat på riktningen hos bränslets accelerationsvektor samt mängden bränsle i tanken. Nackdelen är att det tar ungefär 24 timmar att få fram denna 3-dimensionella representation. Därefter specificeras modellens giltighetsområde och alla tänkbara riktningar hos accelerationsvektorn som påverkar bränslet genereras. För närvarande används 2dimensionella rätblock i simuleringsmodellen för att representera bränsletankarna. dessa används sedan i den automatiserade volymanalysen i CATIA. Denna rapport går igenom de olika stegen i den framtagna metodiken för att kombinera 3. Den nya 3-dimensionella tankmodellen simuleras i Dymola och resultaten jämförs med mätningar utförda i CATIA samt med resultaten från den gamla simuleringsmodellen. ett av dessa system är bränslesystemet. För att kunna utföra mer detaljerade analyser behöver modellerna utökas med en bättre geometrisk beskrivning av bränsletankarna.

.Acknowledgment First of all I would like to thank my supervisor at Saab. I would also like to thank Mehdi Tarkian. She has guided and helped me to succeed with the objectives of this master thesis. Ingela Lind for her commitment and interest. Erik Ocholla fellow student and student reviewer and all the rest that has contributed in one way or another. CATIA and thesis writing in general. Peter Berntsson CAD support at Saab. supervisor at Linköping University for all the tips and all the guidance regarding the approach. Also a thanks to Anders Darander consultant from ChargeStorm.

.

10 1.1 CATIA ------------------------------------------------------------------------------------------------------.7 1.3.17 2.2 Data driven function approximation in MATLAB ----------------------------------------------------.6 DISPOSITION -----------------------------------------------------------------------------------------------------.36 4.20 3 PROPOSED METHODOLOGY --------------------------------------------------------------------------------.3 PURPOSE ---------------------------------------------------------------------------------------------------------.1.3 VOLUME ANALYSIS IN CATIA --------------------------------------------------------------------------------.19 2.2.39 REFERENCES --------------------------------------------------------------------------------------------------------.11 1.22 3.Table of Contents 1 INTRODUCTION ---------------------------------------------------------------------------------------------------.15 2.15 2.1 Computer Aided Design (CAD) with CATIA ----------------------------------------------------------.2 Performance ----------------------------------------------------------------------------------------------.1 DATA PROCESSING ----------------------------------------------------------------------------------------------.1 Why simulate -----------------------------------------------------------------------------------------------.29 3.1.28 3.4 VALIDATION AGAINST MEASURED DATA ---------------------------------------------------------------------.33 4.1 Test system ------------------------------------------------------------------------------------------------.12 1.8 1.33 4.2.2 DEFINE THE AREA OF VALIDITY -------------------------------------------------------------------------------.36 4.1 System Engineering --------------------------------------------------------------------------------------.15 2.2 The tank model today ------------------------------------------------------------------------------------.1 DISCUSSION AND CONCLUSIONS ------------------------------------------------------------------------------.34 4.5 LIMITATIONS ----------------------------------------------------------------------------------------------------.2 INVOLVED DISCIPLINES AND USED TOOLS --------------------------------------------------------------------.1.7 1.5 SUPPORTED TANK GEOMETRIES -------------------------------------------------------------------------------.1 DEVELOP A 3D MODEL OF THE FUEL --------------------------------------------------------------------------.21 3.3.1 BACKGROUND ----------------------------------------------------------------------------------------------------.33 4.3 MODEL SIMULATION IN DYMOLA -----------------------------------------------------------------------------.4 DEVELOP A SURROGATE MODEL ------------------------------------------------------------------------------.2 Divergent problem solving ------------------------------------------------------------------------------.3 Dynamic simulation in Dymola-------------------------------------------------------------------------.2 PROBLEM DEFINITION ------------------------------------------------------------------------------------------.2 RESOLUTION OF THE DATA ------------------------------------------------------------------------------------.21 3.17 2.2.1.1 DEVELOPMENT PROCESS ---------------------------------------------------------------------------------------.23 3.12 1.38 5 CONCLUSIONS----------------------------------------------------------------------------------------------------.35 4.13 2 APPROACH ---------------------------------------------------------------------------------------------------------.12 1.18 Radial Basis Functions ----------------------------------------------------------------------------------.39 5.35 4.16 2.4 OBJECTIVES -----------------------------------------------------------------------------------------------------.31 4 RESULTS ------------------------------------------------------------------------------------------------------------.33 4.2 MATLAB ---------------------------------------------------------------------------------------------------.6 VERIFY PORT POSITIONS ---------------------------------------------------------------------------------------.43 .1.5 IMPLEMENT THE MODEL IN DYMOLA -------------------------------------------------------------------------.1.

RBF (MATLAB FUNCTION) ------------------------------------------------------------------------.72 APPENDIX 13.76 . RUN THE ANALYSIS (CATIA SCRIPT) -------------------------------------------------------------. TRAIN_RBF (MATLAB FUNCTION) --------------------------------------------------------------.55 APPENDIX 7. COPY THE SOLID INTO A NEW PART (CATIA SCRIPT) -------------------------------------------. MAX VOLUME ERROR (MATLAB FUNCTION) --------------------------------------------------.45 APPENDIX 1. PREPARE THE MODEL (CATIA SCRIPT) -----------------------------------------------------------.52 APPENDIX 6.66 APPENDIX 9.58 APPENDIX 8.45 APPENDIX 2.49 APPENDIX 5. SIM_RBF (MATLAB FUNCTION) -----------------------------------------------------------------. CHECK PORTS (CATIA SCRIPT) ------------------------------------------------------------------. HOW TO ACCESS SCRIPTS IN CATIA --------------------------------------------------------------. DIVIDE_DATA (MATLAB FUNCTION) -----------------------------------------------------------. HOW TO INSERT MEASURES IN CATIA ------------------------------------------------------------.APPENDIX ------------------------------------------------------------------------------------------------------------.47 APPENDIX 4.68 APPENDIX 10. PREPARE THE ANALYSIS (CATIA SCRIPT) --------------------------------------------------------.69 APPENDIX 11. RBF_CALC (MATLAB FUNCTION) ----------------------------------------------------------------.73 APPENDIX 14.46 APPENDIX 3. (MATLAB FUNCTION) --------------------------------------------.70 APPENDIX 12. ORIENTATION OF FUEL ACC.

It took over 5000 hours to develop and involved seven simulation and system engineers. 1. (2009) one of the biggest challenges of fuel system design is to cope with the complex geometries of the fuel tanks.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. Lind (2011) explains that engineering aircraft systems is a complex task due to a lot of factors. Figure 1 The tank lay-out of Saab 39 Gripen 7 . mostly due to lack of computer power. The size. When the Gripen was upgraded a major modification was made to the fuel system. Gavel (2007) states that the fuel system is the largest fluid system in the aircraft and consists mostly of several tanks. In order to get a better understanding. 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.1 Introduction This chapter aims to give an introduction to why a 3.1 Background According to Gavel (2007) the complete fuel system of the combat aircraft Saab 39 Gripen was simulated in a full-scale test rig during the initial development. At that point computer power was not an issue and the test rig alone would have become a bottleneck in the development. This can be seen in figure 1. A high interaction between systems and different engineering disciplines are needed. long lead times. expensive tests. expensive equipment. aircraft attitudes and acceleration forces. tank models are needed to compute fuel surface location for various fuel quantities. 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. safety constraints and varying environmental conditions. A decision to build a mathematical model of the system was taken.

sensors. which according to Ullman (2003) means that you need to do right from beginning. but this is not always possible. (2004). laboratory tests and physical prototypes is often time consuming and expensive. modeling is necessary to provide valuable insight into the behavior of the highly non-linear aspects of fuel systems and their functions.1. 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. According to Johannesson et al.. (2009). One way of doing this is to do experiments. Most of the simulations are done in Dymola using Modelica.At the section Vehicle Systems Simulation and Thermal Analysis at Saab Aeronautics in Linköping every basic aircraft system. which is to manage complexity of multi technological products. that the most important issue in product development is the time to market. (2004) states that products today are more complex and consists of many different systems such as mechanical. During a development process all these tools are often used to some extent and it is of interests to have an interaction between them. rescue .and environmental control systems is designed and tested in computer simulations. (2004). A system is defined by Ljung and Glad (2004) as one or more objects whose behavior are to be investigated. This leads to one of the challenges of today‟s product development. A common cause is that the system does not yet exist. 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. 1. landing gear -. A model is a simplified representation of a real system. Xialong Feng. (2004) writes that many tools used for advance modeling. One advantage is by Brooks and Robinsons (2001) that each iteration can be repeated under the same conditions. which is an object. a simulation model is used for testing different parameter setups and components and their effect on the system.oriented modeling language for modeling complex physical systems. 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. According to Langton et al. central processor units (CPU) and control systems. Through fast iteration loops many different setups can be tested. This knowledge of the possible outcome is extremely valuable for companies as it allows an assessment of the risk involved. 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. which includes hydraulic. 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 Why simulate Johannesson et al. power -. According to Johannesson et al. fuel -. power support -. At the same conference another important issue was raised by Dr. power electric. Then a model of the system can be used. Johannesson et al. analysis and simulation are designed for one specific purpose. 8 .

the area in which the model works. For example. get more effective system engineering. reduce the amount of implementation errors. such as training simulators. These ambitions reflect very well with what the research community has mentioned as reasons for model based design. reduce testing time and cost. increase the ability to optimize design for different purposes. Brooks and Robinson (2001) also state that because of simplifications. 9 . for example what happens if the fuel pump in the aircraft stops working? Simulations also provide a safe environment for training. were load cases and configurations can be based on the results from the simulation. effectively use data from tests and also to get better secondary products. According to Lind (2011) the ambition of using model based system engineering at Saab has various reasons. Based on the results from the real tests the model can be updated to better match reality.Brooks and Robinson (2001) also claim that simulations can be used for modeling dangerous situations. to detect problems early. where mistakes can be made without any serious consequences. Ljung and Glad (2004) stress the importance of model validation and the knowledge of the area of validity. gain better control of model variants. the model is not to be trusted completely. reduce project risk. The result needs to be verified through real tests.

During the simulation it is possible to get an animation of how the fuel level varies in the tank. This function calculates the distance from the fuel surface down to the different ports. the distance between surface and ports can be derived. Because the fuel level varies in a 2dimensional plane. 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. This calculation also depends on the aircraft‟s attitude (the orientation of an aircraft‟s axes relative to a reference. The tanks are designed so that the total volume.1. The total pressures at the tank ports are crucial in order to describe the hydraulic behavior of the fuel system. 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. Figure 2 shows an illustration of the tank model and how the fuel is oriented by the acceleration vector. The basic function of the tank model is to calculate air pressure and hydrostatic pressure at connection points. enthalpy and mass flow and updates the mass and energy balances in the fuel system. Kinetic and potential energy terms are neglected in energy balance and the fluid velocity inside the tank in ignored. Fluid temperature is uniform and heat capacitance for the tank walls is not included. The function then returns this information back to the model which calculates pressure. It consists of different components that are linked together by relations and constrains. fluid and port properties are defined and initial values for liquid fuel mass. xy or xz the calculations will be performed in and which components of the acceleration vector that will be used.2 The tank model today The tank model is built in Dymola using the Modelica language. the unused fuel and the position of intake ports are as close to reality as possible.1. based on air. The fuel level is assumed to be perpendicular to the acceleration vector without any time lag. fuel vapor and air. 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. The tank has ideal phase separation between liquid fuel and gas at any time and the fluid consists of liquid fuel. Before any simulation can be performed there is a test that verifies that the ports and test probes are placed within the tank. it has to be specified in which plane. When the ports positions are confirmed the function fuel level is initialized.and fuel flow. Based on the amount of fuel an area in the 2-dimensional plane is created and by using symmetry and given angles. temperature and gas phase composition are set. gas pressure. 10 . Dynamic terms. such as the horizon) and the size and orientation of the acceleration vector.

1. 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. 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. Because of aircraft maneuvering and g-loads. 11 . 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. The fuel tanks contain several sensors for fuel level and a lot of intakes and venting ports.2 Problem definition Representing fuel tanks with rectangular blocks is too simplistic to allow more detailed analysis. the fuel moves around in the tank. A 3-dimensional representation of the actual tank would help answering these questions as it would give a better insight into where the fuel is located. Likewise the sensors must indicate when the aircraft is 100% refueled to prevent overfilling. There are available 3-dimensional models of the fuel tanks made in CATIA V5. It is very important that the engine is not fed by air as that can cause a flameout (failure to the jet engine). so that it can be used for dynamic simulation for system design and in real-time simulators. 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.Figure 2 The tank model with the orientation of the acceleration g and the distance d from fuel surface to a port.

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 method should support a fast. To construct an easy test that verifies that intakes.5 Limitations The tools used for developing this methodology are restricted to the tools used at Saab. The calculated result should have a tolerance of around 10 liters. CATIA and Dymola.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. acceleration and aero elastic deflection. aircraft attitudes and acceleration forces and also the center of gravity for the fuel. 12 . that shows how CATIA and Dymola from Dassault Systèmes can support system development. Develop a 3-dimensional tank model in Dymola that can calculate the hydrostatic pressure at an inlet during simulation of a maneuvering aircraft.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 3-dimensional CATIA model in a dynamic simulation in Dymola. This is an acceptable simplification under normal operating conditions but will clearly break down under any maneuvering when the fuel sloshes. There are also readymade applications for function approximation to be found on the internet for MATLAB. The aero elastic deflection is the structural deformation caused by aerodynamic force. The aero elastic deflection will be neglected in this master thesis because of its small impact and the extra work needed to simulate it. is determined by aircraft orientation. 1. correct and repeatable procedure so that the simulation becomes efficient. the position of fuel inside a tank.1. These applications are a good start and can be rewritten to serve the purpose of this master thesis. 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. venting ports and test probes are placed within the tank geometry. - - 1. the force exerted by the air. Diston et al. Due to previous experiences. Given that Saab has a close cooperation with Dassault Systèmes it is favorable to do as much as possible in their programs. for a given fuel state. MATLAB will be used for the development of a surrogate model. generate real-time code and fit into the existing library. To make a technology demonstrator.

It is assumed that no air pockets exist. Figure 3 The assumed distribution of fuel When the aircraft is being refueled. fuel slosh takes care of giving equal levels. 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. Different aspects of the work are analyzed and potential improvements are presented. since there are always pipes connecting the different compartments of the tank. In other types of geometry. This is shown in figure 3. It also introduces the tools and what they are used for. 13 . Chapter 5 contains discussion and conclusions. 1.6 Disposition Chapter 2 presents some useful models which the development process has been based on. It is also assumed that the fuel is evenly distributed at all time.During this work the fuel level is assumed to be perpendicular to the fuel acceleration vector without any time lag. These pockets will not be dealt with during this master thesis. This is a reasonable assumption. Chapter 3 explains all the steps of this thesis work. air is sometimes trapped in air pockets. The created 3-dimensional tank model is simulated and the result is compared against the old tank model.

14 .

to construct concepts and evaluate them. 2. 2. 15 . In order to simplify the process of concept development.1 Development process When developing a new product it is good to have some structured method to follow. can be used in other contexts and already developed solutions have been put together to serve the purpose of this master thesis. 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. (2004) the philosophy of system engineering is used for developing complex system solutions.1 System Engineering According to Johannesson et al. a product specification is constructed. the concepts have been designed so that they are easy to upgrade. In this master thesis these product specifications are listed as objectives in the introduction. 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. There is also some introduction to the tools used in this master thesis and what they are used for. The next step is to develop the system architecture. for example the use of radial basis functions (RBF) for surrogate modeling and parts of the CATIA scripts. In the system criteria step the collected needs are translated into criteria‟s which the system must fulfill. These needs should be expressed in the users terminology and be as functional as possible. Figure 4 The V-model for system engineering The first step is to identify all the requirements. The process can be described by the so called Vmodel which can be seen in figure 4.1. In this case a concept means a solution on how to use geometry data of any fuel tank from a 3-dimensional CATIA model in a dynamic simulation in Dymola.2 Approach The development process has been based on some useful models which are presented.

In the last step of the development the designed system is split into smaller components which are described in detail and designed. 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. In this step errors in the interfaces and in the interaction between the modules can be detected.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 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. 2.1. It is in this step all compromises and testing strategies are supposed to be identified. the model of an iterative problem solving process is used. In order to develop the best possible component. 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. this was something that evolved during the work. The proposed methodology will be tested and evaluated by the users at Saab to see if the solution satisfies the user needs. 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. which will work together with the other components and meet the requirements of the system (the objectives). but during this master thesis. This means that the data extraction from CATIA is split into a couple of steps. The last test is the user acceptance test. The right side of the V-model is all about verification and validation. 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. During component testing each CATIA script and MATLAB function is tested individually to make sure it works as planned. 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 problem analysis should result in a requirement specification of what the product should be able to perform. 16 . in this case into different scripts and the surrogate modeling is split into different MATLAB functions. The process is explained in figure 5.When the system architecture is done there should be a system solution that fulfills the criteria‟s with available resources.

as design changes can be easily done. from conceptual design and layout of products. CATIA (Computer Aided Three. some for modeling and others for analysis. All available tools in CATIA are distributed in different workbenches. with the sensitivity analysis in mind. If the demands are not fulfilled the concept development starts all over and the concepts are being modified or new ones are developed. 2. 17 .dimensional geometry model into a model that can be used in a dynamic simulation involves 3D modeling and volume analysis in CATIA. then the problem has to be revised and the specifications have to be modified. through strength and dynamic analysis to definition of manufacturing methods. It is mainly used for detailed engineering of 3D models and 2D drawings of physical components. A lot of solutions can be generated as there are many ways to solve a problem. Another advantage is that the design can be parameterized and saved which enables it to be reused in other contexts. All found solutions have to be analyzed regarding properties and performance. development of a surrogate model from the analysis results in MATLAB and finally development of a new tank model in Dymola. During this phase a sensitivity analysis can also be conducted. The concepts are being analyzed once more and this repeats itself until all demands are met.These demands will change during the process as new sub problems and solutions arise and more knowledge about the product is gained. When an acceptable solution has been found the process is completed but there is always the possibility to optimize further. It can be used throughout the whole engineering process. Sometimes it is not possible to meet all the demands. 2. 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.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. for example automotive and aerospace.dimensional representation of the fuel in a tank and also for calculating fuel volume and fuel surface location.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. CAD is a useful help as it lowers product development costs and shortens the design cycle. CAD is used in many applications and industries.2 Involved disciplines and used tools The process of transforming a 3. It is also used to produce animations for special effects in movies. advertising and technical manuals. 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. The next step is to generate solution concepts with a divergent approach.2.

There are different methods to accomplish this. which together build up an overall model of the system. The algorithms and the results are also easy to integrate with external applications and other programming languages.output behavior of the original model for some chosen data points. such a function can be created by using different types of simple.output behavior of the fuel motion in a tank. which imitated the behavior of the original model but is less complex. which makes them unsuitable for routine tasks such as design optimization and sensitivity analysis as it require a lot of simulation evaluations.2 Data driven function approximation in MATLAB Stated by Mathworks (2011) MATLAB is a high-level technical language and interactive environment for algorithm development. Surrogate models are constructed using a data-driven approach. locally linear models in different regions of the collected data. The accuracy of the surrogate model depends on the number and location of samples and also on different sources of errors. In this master thesis the surrogate modeling is about finding a continuous function that explains the nonlinear input. Construction of the surrogate model and optimization of the model parameters Estimation of the accuracy of the surrogate model.2. The results can be visualized both in 2-dimensional and in 3dimensional graphs. data visualization.2. (2005) many design problems require experiments and/or simulations to evaluate how different parameters and constraints affect the results. (2005). data analysis and numeric computation. One way of making these simulations computationally cheaper is to construct approximation models. such as noise in the data or because of the use of an improper surrogate model. 18 . Sometimes these simulations can take long time to perform because of their complexity. known as surrogate models. for example advance curve fitting. According to Queipo et al. The model is based on the input. One option is to use radial basis functions (RBF) to approximate the function. The iterative process of modeling a surrogate model can be divided in three steps:    Sample selection from the original model. MATLAB contains a lot of embedded functions but there are also a lot of toolboxes available separately that provides more specialized functions. According to Queipo et al.

19 . the distance between these two points. where the constant k_i controls the width of the bell.Radial Basis Functions According to Queipo et al. wi. the surface can then be used for interpolating. 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. 1≤ i ≤ nr. are the RBF centres. Which is discussed in Chen. Billings & Luo (1989) Orthogonal least squares methods and their application to non-linear system identification. Φ is a radial function. When enough centres have been found to satisfy the allowed sum-square-error the selection process is aborted. in this master thesis the Gaussian function Φ( x  xi ) = exp(-k_i( x  xi )2) will be used. The functional form of Φ can be chosen among different radial functions. The same problem exists when arbitrarily choosing a sub set of data points as centres. either distributed in a grid or having one centre for each data point. (2005) radial basis functions is used for interpolation of scattered multivariate data. 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. 1≤ i ≤ nr. the orthogonal forward regression least squares algorithm is used. To distribute the centres in a grid may also provide an unnecessary number of centres and may not cover the input domain properly. xi. Starting from a large data set with candidate centres. are the weights and nr the number of centres. x  xi is the Euclidean norm. the centres xi are either chosen to be a subset of the data or distributed uniformly in the input domain. (1990). In order to select the most suitably centres among the data and optimize the number. the algorithm sequentially selects the centre that results in the largest reduction of the sum-square-error between the RBF outputs and the training data. 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. When the training data have been approximated with a surface that provides the best fit to the training data. The surface generated by the Gaussian function looks like a bell. Figure 6 Curve fitting with Gaussian bells According to Chen et al.

It is in Dymola the new 3-dimensional 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. the modified Gram-Schmidt orthogonalization is used to form an orthogonal decomposition of the created matrix.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. by drag and drop or through the text editor. the use of simple standardized components to build larger and more complex models. electrical. 20 . In a mathematical model the dynamic behavior is described by derivatives with respect to time. 2. As read on Modelica (2011) Modelica is an equation based modeling language which is based on the principals of object-oriented modeling. the system is called dynamic. The models are described by differential. If these variables can change without any direct external influence and their value depends on its previous value.2. Dymola uses the open Modelica modeling language for programming. A typical dynamic model consists of equations both with and without variables with derivatives. These models are called differential-algebraic equations models (DAE model) and have to be solved numerical during simulation. and hydraulic and their control systems. algebraic and discrete equations. such as mechanical. In order to make the calculation of the impact on the sum-square-error for each new added centre more efficient. thermodynamic.As the training data from CATIA covers the whole design space and the allowed sumsquare-error is small the training data can be well approximated. but the user is free to create their own libraries or modify the readymade to better match their needs. It makes it possible to simulate the dynamic behavior and the complex interactions between different systems. Modelica contains a model library with standard model components. Models can be created both graphically. According to 3ds (2011b) Dymola is a tool for modeling and simulation of integrated and complex systems.

Some of the subsystems that may be identified are engine feed-. cooling. The space that is of interest is that between all this equipment. What is left is a complex shaped solid which represents the volume of the fuel. fuel is stored in wing tanks on commercial aircraft. Then all different parts such as pipes and ribs. If this space is known the accurate volume and center of gravity for different attitudes could be obtained. A solid is the homogenous representation of an object. refueling-. this is done by the Boolean operator remove in the CAD tool. 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.3 Proposed methodology In this chapter the different steps of this thesis work will be explained. Luckily this has already been done for most of the fuel tanks at Saab. 21 . but in high speed aircraft. wings are small and thin with little internal volume.and explosion protection systems.1 Develop a 3D model of the fuel As stated by Langton et al. fuel transfer-. but the fuselage is also filled with equipment and weapon storage. has to be removed. (2009). the compartment that is filled with fuel. measurement and management-. In order to get this specific volume a new solid has to be created. from 3D modeling in CATIA to dynamic simulation in Dymola. vent and pressurizing-. 3. which are also represented as solid models. The fuselage is therefore used as fuel storage. This new solid is split by the different surfaces of the aircraft‟s body. So the remaining volume for fuel storage involves complex shapes as can be seen in figure 7. In figure 7 some of the equipment can be spotted.

The size of this vector does not matter as it is the direction of it which is of interest. The rotation around the x axis is limited by    . This is done by constraining the rotation around the three aircraft fixe axes shown in figure 8. In appendix 1 there is a MATLAB script Orientation of fuel acc. To define the area of validity for the Dymola model the allowed orientations of the fuel acceleration vector has to be set. 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. 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 orientation of the fuel acceleration vector is used in the volume analysis in CATIA. The orientations are changed in a specified number of steps and all possible orientations within the limits are generated.3. that performs these operations.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. which the final Dymola model is based on.    around the y axis and    around the z axis.

containing the solid. 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. placed at the same coordinates as the original tank model. whose origin is located in front of the aircraft. The new part is opened in a new window and it contains just one body.Figure 8 The aircraft fixed coordinates 3. The VB code for this operation can be found in appendix 3. All models created at Saab refer to the same coordinate system. see figure 9. This is done in order to minimize the file size and make the analysis run faster. 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. When the new window is opened it will just show the coordinate system but if the model is zoomed out or if the fit-to-all button is clicked the tank will be visible. which should make it possible to insert measures through VB scripts and lack of knowledge. This procedure will be repeated for different orientations of the fuel acceleration vector. such as space analysis (SPA). 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. 23 . this makes the file quite big.3 Volume analysis in CATIA The idea is to obtain a data table of different volumes. Tank models available at Saab contain a great deal of references and surfaces that were used when the model was created. some steps has to be done manually. 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. representing the fuel in the tank. This table will be generated by splitting up a solid. Before the script can be run the right name of the tank model has to be entered in the script.

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. named fuel. Also some measures from the bounding box and the total volume of this body are needed for constructing the next steps of this analysis. It is on this new copy. the point in center of gravity and the manually inserted measure inertia. In figure 10 a screen shot from CATIA shows the two bodies in the model tree. named reference. The new body. How to insert measures in CATIA. 24 . that the analysis will be preformed.Figure 9 The copied partbody opened in a new part in a new window. How this is done is explained in appendix 5. When all this is done a measure inertia must be inserted manually on the reference body. 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 result after script Prepare the analysis is shown in figure 11.Figure 10 Screen shot from CATIA showing the reference body. 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. fuel volume. This means that the point with coordinates will always be on the plane. Therefore a point with coordinates is created on the moving plane with the ratio point as a reference. 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. coordinates for a point on the fuel surface and the coordinates for the center of gravity of this fuel. The line represents the orientation of the fuel acceleration vector and will be changed according to all the generated orientations. Prepare the analysis in appendix 6. 25 . The line is created from a point reference and a given length. The result from the analysis should be. the fuel body and the point in the center of gravity VB script number three. which is representing the fuel surface. This guarantees that the line will always go through the whole body. The plane will move when the ratio condition is changed. 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. a movable cutting element is obtained. 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). 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.

For each step the fuel body is split and for the remaining body the volume. resulting in large difference in volume between two cuts. coordinates for the point on surface and coordinates for the center of gravity are calculated and saved. In the following for-loop the cutting plane is moved along the line between the ratio 0. For some orientations of the fuel acceleration vector the number of volume cuts will be quite few.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. When the cutting plane has moved outside of the body the for-loop is aborted. So when the for-loop is aborted the number of performed cuts are calculated and compared against a given minimum amount of cuts. Also the corresponding fuel acceleration vector is saved. which are based on the desired volume difference between two cuts defined by the user. 5 and 0 with a defined number of steps. 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. 26 . 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. The cutting plane starts from the center of the line. from the center of gravity for the tank. y and z components of the line created in script number three is changed according to that orientation. The first orientation of the fuel acceleration vector is loaded and the x. Figure 12 shows this cutting process. In this way it is easy to detect when the cutting plane has moved outside of the tank and no new volumes are formed.

If the model should fail to create the divided body the number -99 is saved to the result file.txt file is needed to create a mathematical model that can be used during dynamic simulation. The data in the . this enables these errors to be found and investigated.The same procedure is repeated for the other side of the fuel body. 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. 5 + the step size and 1 on the line. because it is a basic file format that can be opened and read by most tools for example MATLAB or Dymola. The result is saved in a . shown in figure 13. 5 and 0 Figure 13 The analysis process when the tank is being cut between ratio 0. Figure 12 The analysis process when the tank is being cut between ratio 0. 5 + step size and 1 27 .txt file. between ratio 0.

The function rbf_calc removes all rows containing the number -99. y and z components for a point on the fuel surface. which is the sum of standardized squared errors for the training data. 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. output scaling and max volume can be calculated for each coordinate and saved in the same file. a mathematical expression has to be found and implemented. This is done in order to balance the numerical values in the data. The RBF is usually used for approximation of a single value output. The data table from CATIA containing the orientations of the fuel acceleration vector. rbf_calc see appendix 9. This tolerance is used for aborting the selection of centres. volumes. n is the number of training data. appendix 10. In order to be able to use the result from CATIA in a dynamic simulation in Dymola. tol   (r / L) 2 i 1 n (4) 28 . together with the real constant that controls the width of the bell shape of the Gaussian function used in this RBF approximation. 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. When the data has been loaded the function rbf is executed with this matrix as input as well as the choice of which point.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. These rows correspond to errors from CATIA. This is done through the use of radial basis functions (RBF) which has been implemented in MATLAB and Dymola. 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. weights. The orientation of the fuel acceleration vector. which will lead to a better approximation. Increasing that value widens the bell. because that is easiest. when the model failed to create a divided body. It is also in rbf_calc the acceptable average residual between the training points and the calculated points are set. y and z component for the two points are calculated separately. pre scaling. The point coordinate to be used as output in the RBF approximation is standardizes into a vector of length one. The residuals are standardized with the same length L as the point coordinates. fuel surface or center of gravity to approximate. from that the desired end results can be calculated. The MATLAB script can be found in appendix 8. center points. volumes and the point coordinate is then used in the function divide_data. Favorably there should be a function that gives the x. the results. This residual r in millimeters is used for calculating the tolerance tol (4). The data is being saved in a format which is easy to access through Dymola.3. so the x.

1)   (centerPoin ts (i. These calculations are done for the x. where the centre selection is being performed based on the set tolerance. In the setup for parameters it is possible to choose the right data file for the current tank. If the number of points is fewer than 1000 the data D/2 is send to the function train_rbf found in appendix 11. appendix 12. This repeats itself until all halves has been merged and the best centres that describes the whole dataset has been chosen. it makes some more recursive calls with D/4. for example pressure and flow. which calculates all the port properties that are of interest. The gravitation and acceleration vectors have to be extended to 3 dimensions. to calculate the output and the weights for the RBF approximation. Once the points are fewer than 1000 and the data has been trained and some centres have been chosen. :)) 2 (5) i 1 In the next step the results are multiplied with the corresponding weights (6). 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). When the result has been scaled the coordinate now refers to the original coordinate system used at Saab. The point coordinate is derived from the response surface created by the RBF approximation. nr (1. This distance is of interest when to calculate the pressure at the ports.Because of the large size of the matrix the calculations for finding the centres has to be split into smaller sets. 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. 3. i)  exp(  preScaling (i. If D/2 is greater than 1000. The function divide_data is inspired by the fast Fourier transform algorithm.dimensional representation is just a matter of minor modifications. these centres are sent back to the previous hierarchical level. The old rectangular representation and all 2 dimensional depending parameters have to be deleted. It then makes two recursive calls with D/2 as input. nr point  W   i 1 (6) The result is then scaled by the scaling factor used for standardizing in the MATLAB function rbf_calc. :)  x(1. The calculations are done in a forloop. In the first step the Gaussian functions is calculated. which is done in two steps. otherwise MATLAB will run out of memory. D/8 and so on. y and z coordinate. Basically it splits the data D into two halves if the dataset is greater than 1000 points. Once the simulation is going. 29 . 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. from 1 to the number of RBF centres for one coordinate at the time. The function train_rbf uses the function sim_rbf. weights and scaling factors are imported to the model as parameters. the adaption to a 3. The RBF surrogate model is implemented and the matrices created in MATLAB with chosen centres.5 Implement the model in Dymola Since there is already a tank model in Dymola. After this the parameter point contains the coordinates in millimeter for a point on the fuel surface.

If the distance is positive the port is below the fuel surface and if it is negative the port is above the fuel surface. figure 14. By creating a vector QP between the port and the calculated point Q on the fuel surface. the distance can be calculated with d  QP  cos  . 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 port can be seen as a point P that has given coordinates and the normal n to the fuel surfaces is the acceleration vector.In order to calculate the distance between the surface and the ports. the numerator becomes the scalar between n and QP and the final equation is obtained n  QP  cos  n  QP . The distance of interest is the shortest perpendicular distance between the surface and the port. 30 .:)  point )  g ) / g _ abs where g is the acceleration vector and g_abs the length of it. heightToLevel(i)  ((( portPositi on(i. If this equation is extended with the norm of n. linear algebra with geometry is used.

in other words the planes that touch the geometry.6 Verify port positions In the old 2-dimensional tank model there was a test that verified that the inserted ports were within the tank geometry before the simulation could be performed. These planes are the ones that indicate full volume for every orientation of the fuel acceleration vector. according to figure 14. 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. One idea is based on the distance between ports and the planes that envelops the tank geometry. where the dashed area represents the area in which a port can be recognized as within the tank when it is not. 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. 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 3-dimensional tank model. Figure 15 The area in which a port can be recognized as within the tank when it is not 31 .3. Very strange results can be received from the simulation if the ports are not placed within the tank. This test gives a hint to if the port is within the tank but the test is weak when it comes to convex surfaces.

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 . 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”.csv file. 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. By making these spheres to solid bodies it is possible to check for intersections between these spheres and the tank geometry. This is shown in figure 16 where the red dots are the ports. a test in CATIA is implemented instead. appendix 13. all coordinates to the ports are imported into CATIA and a point is created at each of these coordinates. By running the script Check ports. which in some sense represents the diameter of the inlets that the ports represents. Figure 16 Verification of port position in CATIA 32 .To be able to get a more precise verification. 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. Around each point a sphere is then created. These ports will be interpreted as within the tank by CATIA.

1 CATIA The input to the CATIA analysis is the orientation of the fuel acceleration vector. 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°.1. 33 . This means that within the area of validity there are 900 different orientations that are analyzed in CATIA. containing fewer details.1. 93 GHz dual core computer with 4 GB in RAM. But in order to keep the number of orientations at a manageable level the area of validity is restricted. If a simple tank model. based on the amount of data to be trained but rather the distribution of the data. the calculations done in MATLAB takes approximately 3 – 4 minutes for the point on the fuel surface and for the center of gravity around 7-20 minutes. It is desirable to use as many orientations as possible in order to cover the aircraft‟s whole maneuvering area. is analyzed in the same way it takes just three hours and 45 minutes to execute 35 676 operations.2 MATLAB When all the data from CATIA are to be trained and the RBF centres to be found. If the tolerance is set to decrease the volume error the time increases as more centres have to be found. 4. 3 MB. 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. 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. The file size of the detailed tank model is around 20 MB and for the simple tank 0. The computer used for the analysis has a 2. then 39 hours is required and 29 588 executions are performed.1 Data processing 4.53 GHz dual core processor and 12 GB in RAM. Under normal conditions/normal maneuvering it is acceptable to let the fuel acceleration vector change within ± 20° around the aircraft fixed x coordinate. The same tank is analyzed with an average step size of 12 liters. 360° around the y coordinate and ± 20° around the z coordinate. The calculations are done on a 2.4 Results In this chapter the results from each step is presented in aspects of both time requirements and accuracy. 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. The new 3-dimensional tank model is simulated and the results are compared against the old tank model. It does not seem to be any big difference in execution time. 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. 4.

the maximum volume difference between two cuts as well as the average volume difference between cuts can be seen. gives that each step represents different volumes depending on the orientation of the fuel acceleration vector. the maximum difference between two data points from the analysis are investigated. 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. In order to get a hint of how big this miscalculation caused by the interpolation may be. See figure 17. This means that some data are missing and the step length between two cuts are twice as far as it should be. This problem also exists between the different orientations of the fuel acceleration vector. This interpolation may cause a difference between the actual volume and the calculated one. However this may not affect the model that much. This is because of the fixed step length during the volume analysis. by investigating the data from CATIA the case for which this maximum difference occurred can be found and avoided during simulation. it varies depending on the orientation of the acceleration vector and the shape of the tank. but between the cuts this information is not known. The biggest volume difference between two cuts is quite big. In each cut the exact volume and location of the fuel surface is recorded. which makes a smooth interpolation between the data points (volume cuts). For the analyzed tanks the average volume difference is around 18 liters. It is also displayed for which orientation of the fuel acceleration vector the maximum volume difference is obtained. The values between the cuts are being calculated from the response surface created by RBF. appendix 14. the cross section area. This enables the user to go back to the result file from CATIA and find the reason for this difference. Figure 17 The interpolation problem between two cuts By running the MATLAB script max_volume_error. The geometry of the tank. 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.4.2 Resolution of the data The biggest approximations are made in the volume analysis in CATIA when the fuel volume is being cut. 34 . which results in a big difference in volume between the cuts. 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. depending on how irregular the fuel volume changes between the cuts.

a system component that specifies the acceleration and a source component with table data of the time depending orientation of the acceleration vector. a simple test system was designed in Dymola. r 1 Mm  1000 L (7) 4.3. 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. It consists of the tank model. The system can be seen in figure 18. Figure 18 The test system for the new 3-dimensional tank model 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.1 Test system In order to test the performance and validate the results for the new 3-dimensional tank model. equation 7. The allowed residual will change depending on which tank is used. 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). A residual equal to one liter for each coordinate is acceptable.3 Model simulation in Dymola 4.

The same system with the same input but with the old 2. When the 3.dimensional tanks with 757.4.18) The 3-dimensional tank model in Dymola. A more realistic case was also tested. with maneuvering and fuel consumption. 1007 and 385 RBF centres were used the time increased to 30 minutes plus 10 minutes for compilation. using 757. 355. The difference in distance was then translated into the amount of fuel it represents. The results can be seen in table 1. but remained at a time comparable with just one 3-dimensional tank. The results were also compared against the results from the old 2.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. The used models where:     The geometry model in CATIA (CAD) The 3-dimensional tank model in Dymola. the time did not increase.2 Performance To test the performance of the new 3-dimensional tank model. based on data with a resolution of approximately 12 liters between the data points (3D.dimensional tank model is also simulated and the difference in CPU time for simulation is compared. 93 GHz dual core computer with 4 GB in RAM The time for compilation and simulation of the new 3. causing the fuel surface to move around. was almost three times as long as with the old 2dimensional tank.dimensional tank model in order to see how great the improvement is. a number of simulations were preformed on the test system. 4. The system was also tested with a 3-dimensional tank that used only 385 RBF centres which made the time only one third longer compared with the 2dimensional tank. The whole fuel system was simulated with a real flight case. When the test system was extended to include four different 3dimensional tanks.3. Some of them where the same vectors used for generating the data in CATIA and some are vectors between these.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.12) The old 2.dimensional tanks were used the time for simulating 450 seconds took approximately 10 minutes plus one minute for compilation.dimensional tank model in Dymola (2D) 36 . The acceleration vectors used during these tests where all within the area of validity. using 1009 RBF centres to calculate the fuel level. 1007 and 385 RBF centres. 355.dimensional tank. The simulations are performed on a 2. When the old 2. with different simulation times and with an acceleration vector that alters during the whole simulation.

0.32139.28944.5 0.0.-0.1 0.12 98 102 107 71 4 9 99 98 96 84 1 3 -55 -43 -49 -127 12 6 -18.-0.095492.11698.dimensional tank (3D.889.93969 Distance between fuel surface Difference (mm) and port (mm) CAD 3D.-0.-0.5 81 3 5 Difference (kg) CAD-2D CAD-3D.38705 -0.-0.095492.-0.12 2D CAD-3D.5 171 3 5 CAD-2D 72 59 59 14 61 87 20 71 CAD-2D 40 24 59 7 41 58 63 38 CAD-2D 18 10 59 22 11 7 89 22 This test shows that the 3.-0.18 CAD-3D.93591 -0.12 2D CAD-3D.-0.20074.18 CAD-3D.27) m Acceleration vector -0. 3 kg and for the geometry model and the other 3.097535.0.61581 -0.61581 -0. 37 .93591 -0.11698.12) the difference is 3.0.28944.93591 -0.0.11698.14094.5 34 3 5 Difference (kg) CAD-2D CAD-3D.dimensional model which in average differed 42.0.88988 0.14094.93969 Port (8.-0.-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.18 CAD-3D.-0.0.57) m Acceleration vector -0.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.38705 -0.78183.-0.0.95106 0.3 2.095492.32139.14094. The difference in amount of fuel between the measures from the geometry model and the 3.-0.-0.12 160 4 6 84 0 1 72 10 5 29 2 1 72 6 5 197 1 1 41 0 0.4. It should be mentioned that the results for the 3.88988 0.0.0.095492.0. it is shown that there is a big improvement.18 3D.-0. 0. 4.12 27 4 6 15 0 1 72 10 5 44.22689. 3.12 2D CAD-3D.20074.3 2 1 160 6 5 11 1 1 198 0.7 -23 -21 -63 4.-0.20074. 3.0.122.89371.95106 0.0.18) is in average 3.29389.18 3D.-0.-0.095492.29389.93969 Port (8.-0.95106 0. 1 kg.95106 0.298.-0.78183.0.095492.0. 1 kg.097535.0.-0.95106 0.819) m Acceleration vector -0.29389. When comparing these results against the results from the old 2.43388.0.-0.-0.22689.29389.88988 0.-0.dimensional tank model did not get remarkable better when the accuracy for the centre selection in the RBF approximation was increased.95106 0.dimensional tank model (3D.-0.-0.18 CAD-3D.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) CAD-2D CAD-3D.43388.43388.89371.18 CAD-3D.29389.61581 -0.89371.Table 1Comparison between the results from the different models Port (7.18 CAD-3D.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.12 76 4 6 33 0 1 72 10 5 13 2 1 77 6 5 112 1 1 136 0 0.097535.1 0.18 3D.78183.0.29389.38705 -0. 0.-0.22689.28944.318.32139.1 0. -0.

Some of the tested geometries are shown in figure 19.4.5 Supported tank geometries The methodology has been developed to support any kind of 3. representing some of the available tank geometries at Saab.dimensional tank models in Dymola. Figure 19 Examples of tested geometries 38 . The developed methodology has been used to create 3.dimensional geometry as the shape of the tanks used at Saab varies a lot.

1 Discussion and conclusions The purpose of this master thesis was to investigate and develop a methodology for using 3-dimensional CATIA models in simulations in Dymola. It is possible that these restrictions are set to narrow. Outside of these restrictions the results cannot be trusted as the RBF has problems extrapolating the needed response surface. the time for generating the data table is around 20 hours. 5. The developed methodology reduces the difficulties and the approximation errors that occur when modeling the tanks as rectangular blocks. The result. which has a file size of approximately 20MB after the simplification done by script Copy the model. This in turn gives the possibility to perform more accurate pressure and flow calculations on the fuel system. With the new 3dimensional representation it is also possible to find the best placement for fuel probes. This means that the results from the simulation do not fully correspond to the real system but they are good enough.5 Conclusions In this chapter different aspects of the proposed methodology are analyzed and potential improvements and areas of further development are presented. In order further verify the model the results should be compared against the results from a real test flight. 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. the results are only credible inside the given angles for the fuel acceleration vector. Based on the measured result the conclusion can be drawn that the 3-dimensional tanks does give a better approximation of the reality than the old 2-dimensional. One problem with the found methodology is that the analysis in CATIA takes a lot of time. The only restriction is the area of validity. but it seems that most test flight cases are within the area of validity. It is important to remember that there have been assumptions and simplifications in every step of this developed methodology. For the tested tank geometries. 39 . 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. This is of great help when to interpret the results from the simulation. 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. A big advantage with this methodology is that it is possible to determine how accurate the model is compared to the CAD model. The proposed methodology is one way of doing this and as the results shows the outcome is acceptable. Moreover the presented framework enables calculation of unused fuel in the tank and the possibility to better calculate the aircraft‟s center of gravity. intake and venting ports as the location of the fuel surface is better known. all ports can be placed at their original positions and the result is equally good for all orientations of the fuel acceleration vector.

When the first batch is done. the program should restart CATIA and load it with a new batch. If a good enough approximation of the tank models could be made.With more powerful computers.dimensional tank model in Dymola there was an animation of how the fuel moved around and decreased in the tank. In order to make this work the first macros has to be run manually as there are manual steps in them. If none of the above is possible there is the option to create a program that runs the volume analysis in CATIA in batches. Maybe it is possible to reduce the number of executions in CATIA. these problems would be smaller but that is not the right action to take. load a subset of orientations for the fuel acceleration vector and execute the analysis macro. It would also be possible to get the desired data from a complete full and empty tank. As it is now. How to execute CATIA scripts in batch mode is discussed by CATIA V5 Automation (2011). the file size and the execution time could be heavily reduced and the result would still be better than the rectangular representation. This bounding box method should be created so that it does not affect the execution time negatively. the data recording is aborted when the cutting plane has moved outside the tank. which results in a rougher model with fewer surfaces. This body can then be represented by different available standard shapes or it can refer to CAD data for visualization. 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. The existing problem with the step size also makes it hard to set the desired average volume between two cuts. (2005). This is discussed by Seo et al. Simply the program should start CATIA. As other simplifications are made in the methodology perhaps the original tank model does not need to be 100 % accurate. This leads to the fact that the last recorded data has the value from the last cut that was within the tank. investigating fewer orientations and/or volumes in order to shorten the execution time. Then the step size could be adjusted so that each step represents equal amount of fuel. 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. In this way CATIA will execute the analysis pretty fast as it operates with a lot of available RAM memory at all time. When that is done the model could be saved and the created “batch program” could be used. A similar animation for the new 3-dimensional 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. This means that the accuracy in the model varies during a flight case. In the old 2. It seems that the results always contain a larger average volume step than the set one. With the criteria of a minimum amount of cuts for each orientation this is solved to some extent. 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 could be made by some sort of wrap-around technique. In Dymola a BodyShape can be used to represent a body. The model verification shows that even the simulation based on fewer executions in CATIA resulted in good accuracy. 40 .

the result from CATIA.Another option is to let CATIA take care of the animation. During the simulation on the entire fuel system it becomes very demanding for Dymola when the fuel level is stationary at an inlet. by linking the result from the simulation to the tank model in CATIA. This is left to be investigated by Dassault Systèmes. the problem with convex surfaces has to be solved and also more planes has to be created in order to encapsulate the entire tank. There is a possibility that each tank has its own optimal parameter settings as the shape of the tank differs. 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. for example the number of executions in CATIA. 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. In almost every step of the proposed methodology there is a tradeoff between accuracy and execution time. Perhaps it is even possible to develop a similar surrogate model which was done in MATLAB directly in Dymola. 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. It would be desirable to find the best tradeoff by experimenting with the parameters that are possible to change. where Dymola is integrated into CATIA. This should work but would take longer time as the table is very big and the interpolation is done in a four dimensional space. the CPU time for simulating the 3-dimensional tank models could become comparable with the old 2-dimensional. This has to be further investigated. If this can be solved. but it would have been more appropriate if everything was done in CATIA and Dymola. the shape of the Gaussian bells and the residual used when selecting centres etcetera. One alternative to accomplish this is to let Dymola searches through the created data table. to find a matching value each time the orientation of the fuel acceleration vector or volume is changed in the simulation. 41 . This feature is available in CATIA V6. 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 objective of creating a technology demonstrator for Dassault Systèmes has been accomplished. 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.

42 .

N & Grant. Elsevier. J. ISBN 0-79430-3 Gavel.& Tucker P. Nos. Cowan.D. J-G & Pettersson. (2005) Surrogate-based analysis and optimization. R. Hewitt. D. UK Lind. Ltd.G (2003) The Mechanical Design Process. R & Robinson. Internal Journal of Control. Third Edition. pp. ISBN 91-47-05225-2 Langton. Department of Mechanical Engineering. 67-76 Queipo N. 50:5. M.. S ( 2001) Simulation. H (2007) On Aircraft Fuel Systems – Conceptual Design and Modeling. M & Richards. Y.1067. 1327 1350 Diston. Haftka R. John Wiley and Sons. Studentlitteratur.T.effektiva metoder för konstruktion och design. BEA Systems plc. Goel T. 1-4. 1873 1896 Chen.R & Spicer. Progress in Aerospace Sciences. D (2004) Produktutveckling . I & Andersson. pp. Warton Aerodrome. Y & Chae.M (1990) Practical identification of NARMAX models using radial basis functions.References Printed Brooks. H. 1-28 43 . 2011 Seo.V. S. Palgrave. Dresden. Computer-Aided Design & Applications. Choi.. Billings. 52:6. 2.K. Shyy W.A. S. Tookey. Lee. Liber AB. The McGraw-Hill Companies.A & Lou. Linköpings University. S. Song. Preston PR4 1AX. L (2009) Aircraft Fuel Systems. S (2005) Wrap-around operation for multi-resolution CAD model. J.M Multi-Disciplinary Modelling for System Integration. Lund. K. P. Billings. ISBN 978-1-56347-963-2 Ljung. Inc. Kim. C. ISBN 91-44-02443-6 Ullman. T ( 2004) Modellbygge och simulering. S. Division of Machine Design. 41. Operational Research Series. L & Glad. Persson. H (2011) Model Based Systems Engineering for Aircraft Systems – How does Modelica Based Tools Fit? In proceedings of the 8th International Modelica Conference. Dissertation No. andra upplagan. Clark.. S. G.. Vol.F. Vaidyanathan R. ISBN 0-07-112281-8 Papers Chen. Internal Journal of Control. Vol. C. ISBN 978-91-85643-04-2 Johannesson. W (1989) Orthogonal least squares methods and their application to non-linear system identification.

ABB (2011) Model. A. http://www.com/2010/09/26/exec-scripts-in-batch-mode/ Viewed 29/8/2011 Mathworks (2011) Matlab.wordpress. Linköping 8-9 February. Thorp. 2011. Enginsoft Nordic AB (2011) Multi-objective optimization using modeFRONTIER.3ds. Linköping 8-9 February.com/fileadmin/PRODUCTS/CATIA/PDF/CATIAbd. 44 .html Viewed 2/6/2011 Modelica (2011) Modelica. http://www. http://v5vb.mathworks.3ds. http://www.pdf Viewed 11/4/2011 3ds (2011b) Dymola.org/ Viewed 6/6/2011 Verbal Feng. https://www.driven Design and Optimization of Industrial Robots at ABB.com/products/catia/portfolio/dymola/overview/ Viewed 2/6/2011 CATIA V5 Automation (2011) Executing CATIA scripts in batch mode. X. Presented during 5th MODPROD Workshop on Model-Based Product Development.modelica.com/products/matlab/description1.Electronic 3ds (2011a) Design Excellence for Product Success. 2011. Presented during 5th MODPROD Workshop on Model-Based Product Development.

0 sin(phi(i)) cos(phi(i))]. temp = [Rz*Rx*Ry*Vs]'. %Generates all possible combinations of phi.vector V = [].20 degrees in 5 steps (steps of 10 degrees) = linspace(-pi.-sin(theta(j)) 0 cos(theta(j))]. rotation in 3 dimensions. +/.pi/9. +/. Orientation of fuel acc.20 degrees in 5 steps(steps of 10 degrees) Vs = [0 0 1]'.pi.csv'.temp].0 1 0.0 cos(phi(i)) -sin(phi(i)).sin(psi(k)) cos(psi(k)) 0. %angle between x and z. for k = 1:size(psi. +/. %Based on angle changes.1) Rx = [1 0 0.Appendix Appendix 1.pi/9.theta and psi for i = 1:size(phi. %angle between x and y.5)'. %angle between y and z. %rotation in 3 dimensions V = [V.1) Rz = [cos(psi(k)) -sin(psi(k)) 0.V) %Saves the data in the matrix V in a csv file in your working directory %The name of the file is accVector 45 .5)'. for j = 1:size(theta. (MATLAB function) %Generates a csv file with the components of the acceleration vector.180 degrees in 36 steps(steps of 10 degrees) linspace(-pi/9.0 0 1].1) Ry = [cos(theta(j)) 0 sin(theta(j)). %starting. phi = split theta split psi = split linspace(-pi/9. end end end csvwrite('accVector.36)'.

In order to be able to use the scripts.Appendix 2. 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. the folder in which they are stored must be added as a library in CATIA. 46 . The scripts will now be visible and you can run them by simply choose one of them and click “Run”. Click the button “Create new library” and enter the path to the right folder. How to access scripts in CATIA The VB macros is accessible though the top menu in CATIA under Tools → Macro → Macros.

Clear Set part1 = partDocument2.Item("FUEL TANK 3.WindowState = catWindowStateNormal Set windows1 = CATIA.CREATE A NEW PART ----------------------------------------------------Set documents1 = CATIA.Add("Part") Set specsAndGeomWindow1 = CATIA.Appendix 3.Documents Set partDocument1 = documents1. Sub CATMain() '-------------------------------.Selection selection1.Activate '------------.Copy 47 .Bodies Set body1 = bodies1.CATPart") 'THE ITEM " " SHOULD BE THE NAME OF THE ORIGINAL TANK FILE specsAndGeomWindow2.Part Set bodies1 = part1. 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.Item("PartBody") selection1.Windows Set specsAndGeomWindow2 = windows1. 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.Add body1 selection1.ActiveDocument Set selection1 = partDocument2.ActiveWindow specsAndGeomWindow1.

Count Set BodyToRename = partDocument1.name = "reference" part2.PartNumber = "Tank for analysis" '-------------------.Item(i) BodyToRename.Update End Sub 48 .Selection selection2.Bodies.Activate Set part2 = partDocument1.part.INSERT THE COPY IN THE NEW PART -------------------------------------specsAndGeomWindow1.part.RENAME THE NEW PART TO "TANK FOR ANALYSIS" ---------------------Set product1 = partDocument1.RENAME THE COPIED BODY TO "REFERENCE" -----------------------------i = partDocument1.Bodies.'------------------------.Add part2 selection2.GetItem("Part2") product1.clear selection2.clear '-------------------.PasteSpecial("CATPrtResultWithOutLink") selection1.Part Set selection2 = partDocument1.

HybridShapeFactory Set coordinatepoint = hybridShapeFactory1. Sub CATMain() '------------------------. Prepare the model (CATIA script) 'THIS SCRIPT CREATES A NEW GEOMETRICAL SET IN WHICH ALL 'REFERENCES FOR THE ANALYSIS WILL BE STORED.CREATE DATUM POINT "CoG" ----------------------------------------Set coordpkt_ref = part1.Add() hybridBody1.Item("Analysis_References") arm_ref.Part Set hybridBodies1 = part1.AddNewPointDatum(coordpkt_ref) arm_ref.Update '----------------------.HybridBodies.ActiveDocument Set part1 = partDocument1.UpdateObject hybridBody1 '-----------------------.AppendHybridShape datumpoint hybridShapeFactory1.DeleteObjectForDatum coordpkt_ref datumpoint.CreateReferenceFromObject(coordinatepoint) Set datumpoint = hybridShapeFactory1. 0. 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.000000.CREATE COORDINATE POINT ---------------------------------------Set hybridShapeFactory1 = part1.AddNewPointCoord(0. 0.CREATE GEOMETRICAL SET ---------------------------------------Set documents1 = CATIA.Appendix 4.name = "Analysis_References" part1.000000) Set arm_ref = part1.000000.name = "CoG" 49 .Documents Set partDocument1 = CATIA.AppendHybridShape coordinatepoint part1.HybridBodies Set hybridBody1 = hybridBodies1.

Copy selection2.Selection Set selection2 = partDocument1.Count Set BodyToRename = partDocument1.Item("CoG") Set formula1 = part1.Selection selection1.Clear selection1.Update '---------------------.Bodies.CreateFormula("COG_Formula".Add body1 selection1.Item("reference") selection1. COGpointparameter.Add part1 selection2.Update '----------------------.Item(i) BodyToRename.RENAME THE NEW BODY TO "fuel" ---------------------------------i = partDocument1.part. "".Hidden = True part1.Update 50 .name = "fuel" part1.'-----------------------. "centerofgravity(reference)") formula1.Relations.Parameters.COPIES REFERENCE BODY TO A NEW BODY ---------------------Set selection1 = partDocument1.MOVE DATUM POINT TO CENTER OF GRAVITY --------------Set COGpointparameter = part1.Clear Set bodies1 = part1.PasteSpecial("CATPrtResultWithOutLink") selection2.part.Bodies.Clear part1.Bodies Set body1 = bodies1.

'-------------------.SetShow catvispropertynoshowattr part1.REMINDES THE USER OF INSERTING A MEASURE --------------selection1.Update msgBox("Insert a Measure Inertia on the reference body and rename it to inertia_reference") End sub 51 .VisProperties VisPropset1.HIDES THE REFERENCE BODY AND ---------------------------------'-------------------. Add body1 Set vispropset1 = selection1.

Then “OK”. center of gravity and principal axes are checked see figure 2. Then the dialog box seen in figure 1appears. Figure 1Measure Inertia Figure 2 What to calculate 3. Click on the button “Customize” and a new dialog box appears. This step by step guide is directly applicable to the steps that are to be done manually in this master thesis. To change the name of it just right click on it and choose “properties”. Make sure that volume. To insert measure inertia on a body: 1. 2. How to insert measures in CATIA There are two types of measures in CATIA. The measures have now appeared in the structure tree. Make sure that “Keep measure” is checked in figure 1 and then “OK” 5.Appendix 5. Both will be used and are therefore explained. See figure 3. 4. The measure on the reference body should be named inertia_reference and the measure on the fuel body should be named inertia_fuel . 52 . Choose which body you want to measure by clicking on the geometrical representation or at the name in the structure tree on the left. measure inertia and measure between. Click the “measure inertia” button in the bottom toolbar.

Click the “measure between” button in the bottom toolbar. Figur 4 Measure Item 3. 2.Figur 3 How to find properties To insert a measure on the point_on_fuel_surface: 1. Then the dialog box seen in figure 4 appears. Choose point_on_fuel_surface from the structure tree. Make sure that “Keep measure” is checked in figure 4 and then “OK” 53 .

5. as in figure 3.4. To change the name of it just right click on it and choose “properties”. The measures have now appeared in the structure tree. 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”.

CALCULATE THE GREATEST DISTANCE IN -----------------'---------------------------THE BOUNDING BOX FOR THE TANK --------------------------Set lengthx = parameters1. POINTS. Sub CATMain() '----------------------------------------------------------------------------------------------------------Set partDocument1 = CATIA.Item("Analysis_References") Set hybridShapes1 = hybridBody1.value^2 + lengthz.Part Set hybridBodies1 = part1.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 .HybridShapes Set parameters1 = part1.value^2)^(1/2)) lengthyz = ((lengthy.Parameters '-------------------------.Item("Tank for analysis\inertia_reference\BBLx") 'THE ITEM " " MUST MATCH THE NAME OF THE PART Set lengthy = parameters1.ActiveDocument Set part1 = partDocument1.Item("Tank for analysis\inertia_reference\BBLy") 'THE ITEM " " MUST MATCH THE NAME OF THE PART Set lengthz = parameters1. PLANES AND CUTING 'ELEMENTS THAT WILL BE USED DURING THE ANALYSIS.value^2)^(1/2)) lengthxz = ((lengthx.value^2 + lengthy. Prepare the analysis (CATIA script) 'THIS SCRIPT CREATES ALL LINES.HybridBodies Set hybridBody1 = hybridBodies1.Item("Tank for analysis\inertia_reference\BBLz") 'THE ITEM " " MUST MATCH THE NAME OF THE PART lengthxy = ((lengthx.Appendix 6.value^2 + lengthz.

'---. 0.Item("Absolute Axis System") Set reference1 = part1. False) hybridBody1.-----. length/2.AppendHybridShape hybridShapeLinePtDir1 hybridShapeLinePtDir1. -length/2.CreateReferenceFromObject(hybridShapeLinePtDir2) Set hybridShapePointOnCurve2 = hybridShapeFactory1.FIXED LENGTH OF THE GREATEST DISTANCE IN THE BOUNDING BOX --Set hybridShapeFactory1 = part1.Update '-------------.AddNewDirectionByCoord(0.AddNewLinePtDir(reference1. 1) Set axisSystems1 = part1.0.CREATE A REFERENCE POINT ON THE LINE "acc_vector" -------------Set hybridShapeLinePtDir2 = hybridShapes1. 0. NORMAL TO THE LINE "acc_vector" ----------'----------.AND FIXED AT THE POINT "point_reference"---------------------------Set reference4 = part1. False) hybridBody1.HybridShapeFactory Set hybridShapePointOnCurve1 = hybridShapes1.CREATE A LINE THAT IS FIXED AT CoG AND HAS A ----------------------------'---.Update '-----------------.CreateReferenceFromObject(hybridShapePointOnCurve2) 56 .CreateReferenceFromObject(hybridShapePointOnCurve1) Set reference2 = part1.CreateReferenceFromObject(axisSystem1) hybridShapeDirection1.AddNewPointOnCurveFromPercent(reference3.Item("acc_vector") Set reference3 = part1.Item("CoG") Set hybridShapeDirection1 = hybridShapeFactory1.name = "point_reference" part1.CreateReferenceFromObject(hybridShapeLinePtDir2) Set reference5 = part1. hybridShapeDirection1.name = "acc_vector" part1.AppendHybridShape hybridShapePointOnCurve2 hybridShapePointOnCurve2.CREATE A PLANE.RefAxisSystem = reference2 Set hybridShapeLinePtDir1 = hybridShapeFactory1.AxisSystems Set axisSystem1 = axisSystems1.

name it point_on_fuel_surface ") End Sub 57 .Set hybridShapePlaneNormal1 = hybridShapeFactory1.CreateReferenceFromObject(hybridShapePointOnCurve2) hybridShapePointCoord1.000000.SPLIT THE BODY "fuel" WITH THE CREATED PLANE ------------------'-------------.RefAxisSystem = reference7 hybridBody1. reference5) hybridBody1.AppendHybridShape hybridShapePlaneNormal1 hybridShapePlaneNormal1.AddNewPointCoord(0.Y.AddNewSplit(reference8.000000.name = "point_on_fuel_surface" part1. 0.ShapeFactory Set reference8 = part1.CreateReferenceFromName("") Set split1 = shapeFactory1.CreateReferenceFromObject(hybridShapePlaneNormal1) split1.Update '-------------.Update '-----------.Surface = reference9 part1.CreateReferenceFromObject(axisSystem1) hybridShapePointCoord1. catPositiveSide) Set reference9 = part1.PtRef = reference6 Set reference7 = part1.CREATE A POINT ON THE FUEL SURFACE WITH X.AddNewPlaneNormal(reference4.AND REMIND THE USER TO INSERT MEASURES -----------------------Set shapeFactory1 = part1.Update msgBox("Insert a Measure Inertia on fuel and rename it to inertia_fuel. Also measure the point_on_fuel_surface.AppendHybridShape hybridShapePointCoord1 hybridShapePointCoord1.name = "fuel_level" part1. 0.Z COORD ------Set hybridShapePointCoord1 = hybridShapeFactory1.000000) Set reference6 = part1.

Item("fuel") Set selection1 = partDocument1.Bodies Set body1 = bodies1. THE ITEM MUST MATCH THE NAME OF THE 'PART -------------------------------------------------------------------------------------------------------Set parameters1 = part1.Item("Tank for analysis\Analysis_References\point_reference\Ratio") Set volume_ref = parameters1.Item("Tank for analysis\Analysis_References\acc_vector\Y") Set realParam3 = parameters1.THE PARAMETERS ARE SET.Item("Tank for analysis\Analysis_References\acc_vector\Z") Set ratio = parameters1.OpenAsTextStream("ForReading") Set partDocument1 = CATIA. 'FROM EACH CUT THE VOLUME OF THE REMANING BODY.Item("Tank for analysis\Analysis_References\acc_vector\X") Set realParam2 = parameters1.FileSystem Set oFile = oFileSys. 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.Selection selection1.Part Set bodies1 = part1.LOOP THAT 'MOVES THE CUTTING PLANE ALONG THIS LINE AND SPLITES THE BODY "fuel".VisProperties CALCULATIONS VisPropset1.SetShow catvispropertynoshowattr part1.Parameters Set realParam1 = parameters1.Update '----------. Add body1 Set vispropset1 = selection1.csv") 'THE LOCATION OF THE CSV FILE WITH THE ORIENTATIONS OF THE ACC-VECTOR Set Stream = oFile. Run the analysis (CATIA script) 'THIS SCRIPT IMPORTS COORDINATES FROM A CSV FILE AND CHANGES THE 'ORIENTATION OF THE LINE "acc_vector". Sub CATMain() '--------------------------------------------------------------------------------------------------------------------Set oFileSys = CATIA. IT ALSO EXECUTES A FOR.ActiveDocument Set part1 = partDocument1.Item("Tank for analysis\inertia_reference\Volume") 'HIDES THE FUEL BODY TO SPEED UP 58 .GetFile("H:\My Documents\CAD\Ny indata\accVector.Appendix 7.

" WITH ".Value*StepSize ostream.CreateFile(filename & ".Write (" "& Chr(10)) '---------.CREATES AND OPENS THE RESULT FILE -------------------------------------------filename = CATIA. CoGx. CoGy. Point z.FileSystem.REPLACES THE DECIMAL SEPERATER ". Volume.FileSelectionBox("Where do you want to save the result file". StepLength = " & StepLength & Chr(10)) ' THE HEADERS FOR THE COLUMNS ostream.READS THE CSV FILE AS LONG AS THERE IS ANY LINE TO READ --------------While Not Stream.txt".'--------------.value*1000)/averageVolumeError) 'MAKES EACH CUT REPRESENT THE AVERAGE VOLUME ERROR '-------.Close ostream.") 'THE TEXT LINE IS SPLIT INTO WORDS BY " .CALCULATES THE LENGTH OF EACH STEP AND WRITES IT IN THE RESULTS 'FILE HEADER ------------------------------------------------------------------------------------------------Set length1 = parameters1. " '---." 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 .Close msgBox("The analysis was done " & now) WAS FINISHED Exit sub End If '-.Item("Tank for analysis\Analysis_References\acc_vector\End") StepLength =2* length1. CatFileSelectionModeSave) Set Datos = CATIA. Point y.OpenAsTextStream("ForAppending") '--. "*.AtEndOfStream sLine = Stream. Point x.Write ("n_x. CoGz.txt" . n_z.STOPS THE CODE FROM ERROR IF THERE IS AN EMPTY LINE AT THE END OF 'THE INPUT FILE -------------------------------------------------------------------------------------------If UBound(sWord) = "-1" Then Stream. n_y.ReadLine sWord = Split(sLine.THE NUMBER OF STEPS THAT THE LINE "acc_vector" WILL BE DEVIDEED INTO --averageVolumeError = 10 'LITERS StepSize = 1/((volume_ref. True) Set ostream = Datos.".

" & "-99" & ".5 To 0 step ." & "-99" & ".Value = j On Error Resume Next 'DISABLES ALL ERRORS part1.Value = X realParam2.".Write ("-99" & "." & "-99" & "." & "-99" & Chr(10)) 'WHAT TO WRITE IN THE RESULT '----." & "-99" & ".X = Cstr(Replace(sWord(0).Value = Y realParam3." & "-99" & "." & "-99" & ".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.Value = "0" Then Exit For 60 . " .Value = Z '------.Item("inertia_fuel\Gx") Set CoGy = parameters1.Item("point_on_fuel_surface\Gz") ratio.IF THE CENTER OF GRAVITY IS ZERO THE VOLUME IS ALSO ZERO AND WE 'HAVE MOVED OUTSIDE THE TANK AND THE FOR-LOOP IS ABORTED --------------Elseif CoGx.Item("inertia_fuel\Gz") Set pointx = parameters1.Item("inertia_fuel\Volume") Set CoGx = parameters1.Value = "0" And CoGz.". " . ".StepSize Set Volume = parameters1.")) realParam1.IF AN ERROR IS DETECTED ALL VALUES ARE SET TO NOTHING AND YOU CAN 'DECIDE WHAT TO WRITE IN THE RESULT --------------------------------------------------------If Err.")) Z = Cstr(Replace(sWord(2)." & "-99" & "." & "-99" & ". " .Update '----.".MOVES THE CUTTING PLANE IN ONE DIRECTION BY CHANGING THE RATIO 'ON THE LINE -----------------------------------------------------------------------------------------------For j = 0.Item("inertia_fuel\Gy") Set CoGz = parameters1.Item("point_on_fuel_surface\Gx") Set pointy = parameters1.")) Y = Cstr(Replace(sWord(1).Value = "0" And CoGy. ".

" & pointy & ".Value = k On Error Resume Next 'DISABLES ALL ERRORS part1." & CoGy & ". ".")) CoGz = Cstr(Replace(CoGz. ". ". ". ".". ".Value.Item("point_on_fuel_surface\Gy") Set pointz = parameters1.". ". "." & Volume & ".Item("inertia_fuel\Gx") Set CoGy = parameters1.")) CoGy = Cstr(Replace(CoGy.Item("inertia_fuel\Volume") Set CoGx = parameters1.".Write (sWord(0) & ".Value. THIS TIME IN SMALLER PIECES --------------------------------------------If (j-0.Volume.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 FOR-LOOP IS ABORTED ---------------------------------------------------Elseif (volume_ref.StepSize Set Volume = parameters1.Update 61 .")) CoGx = Cstr(Replace(CoGx." & CoGz & ". ".".Item("inertia_fuel\Gy") Set CoGz = parameters1." & sWord(1) & ". ". SO THE VOLUME IS BEING CUT 'ONCE MORE.")) pointy = Cstr(Replace(pointy.")) pointz = Cstr(Replace(pointz.Item("point_on_fuel_surface\Gz") ratio.Value) < 0.5)/(-StepSize) < (1/StepSize)/4 Then For k = 0. "."." & sWord(2) & ".".Item("point_on_fuel_surface\Gx") Set pointy = parameters1.Value.Item("inertia_fuel\Gz") Set pointx = parameters1.IF THE NUMBER OF CUTS ARE FEW IT MEANS THAT THERE IS A BIG 'DIFFERENCE IN VOLUME BETWEEN TWO CUTS." & pointx & ".Value. ".")) ostream."." & pointz & Chr(10)) End If On Error GOTO 0 Next 'ERRORS ARE ENABLED '----.THE VALUES FROM THE MEASURES ARE CHANGED INTO A TEXT WITH A ".'---.Value.5 -(StepSize/2) To 0 step . ".Value .Value." & CoGx & ".Value.")) pointx = Cstr(Replace(pointx.00000001 Then Exit For Else '----. "." 'AS DELIMITER AND IS WRITEN TO THE RESULT FILE -----------------------------------Volume = Cstr(Replace(Volume.

" & "-99" & ".THE VALUES FROM THE MEASURES ARE CHANGED INTO A TEXT WITH A ".")) pointy = Cstr(Replace(pointy.Value. ".Value) < 0.Value = "0" And CoGy. "." & "-99" & ". ". ".Value." & "-99" & "." & "-99" & ".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 FOR-LOOP IS ABORTED -----------------------------------------------------------Elseif (volume_ref." & CoGx & "." & sWord(1) & ". "." & "-99" & Chr(10)) 'WHAT TO WRITE IN THE RESULT '----------.Value ." & "-99" & ".".".Value." & pointx & ".Value." & sWord(2) & ". ".Value." & CoGy & ".")) CoGy = Cstr(Replace(CoGy.Value = "0" Then Exit For '---------. ".IF AN ERROR IS DETECTED ALL VALUES ARE SET TO NOTHING AND YOU 'CAN DECIDE WHAT TO WRITE IN THE RESULT -----------------------------------------------If Err. ".Value = "0" And CoGz. "." & Volume & "." & CoGz & ".")) CoGx = Cstr(Replace(CoGx." & "-99" & "." & "-99" & "." & pointz & Chr(10)) End If On Error GOTO 0 Next 'ERRORS ARE ENABLED 62 . "." 'AS DELIMITER AND IS WRITEN TO THE RESULT FILE --------------------------------------Volume = Cstr(Replace(Volume. ". "." & "-99" & ".".")) pointx = Cstr(Replace(pointx.")) CoGz = Cstr(Replace(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." & pointy & ".Write (sWord(0) & ".Volume.Value.00000001 Then Exit For Else '------.Write ("-99" & ". ".")) pointz = Cstr(Replace(pointz.".'---------.Value. ".")) ostream.IF THE CENTER OF GRAVITY IS ZERO THE VOLUME IS ALSO ZERO AND 'WE HAVE MOVED OUTSIDE THE TANK AND THE FOR-LOOP IS ABORTED -------------Elseif CoGx.

00000001 Then Exit For 63 .IF AN ERROR IS DETECTED ALL VALUES ARE SET TO NOTHING AND YOU 'CAN DECIDE WHAT TO WRITE IN THE RESULT --------------------------------------------------If Err.5 + StepSize To 1 step StepSize Set Volume = parameters1.Value = "0" Then Exit For '---------." & "-99" & "." & "-99" & "." & "-99" & ".Value .Else End If '------------.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 FOR-LOOP IS ABORTED ---------------------------------------------------Elseif (volume_ref.MOVES THE CUTTING PLANE IN THE OTHER DIRECTION BY CHANGING 'THE RATIO ON THE LINE --------------------------------------------------------------------------For i = 0.Write ("-99" & ".Item("point_on_fuel_surface\Gz") ratio.Update '-----------.Value = "0" And CoGz." & "-99" & "." & "-99" & Chr(10)) 'WHAT TO WRITE IN THE RESULT '----------.Item("inertia_fuel\Gz") Set pointx = parameters1.Value) < 0.Volume.Item("point_on_fuel_surface\Gy") Set pointz = parameters1.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\Volume") Set CoGx = parameters1.Value = "0" And CoGy.Value = i On Error Resume Next 'DISABLES ALL ERRORS part1." & "-99" & "." & "-99" & ".Item("inertia_fuel\Gy") Set CoGz = parameters1.Item("point_on_fuel_surface\Gx") Set pointy = parameters1.IF THE CENTER OF GRAVITY IS ZERO THE VOLUME IS ALSO ZERO AND 'WE HAVE MOVED OUTSIDE THE TANK AND THE FOR-LOOP IS ABORTED -------------Elseif CoGx." & "-99" & ".Item("inertia_fuel\Gx") Set CoGy = parameters1." & "-99" & ".

Value.Write ostream.")) CoGx = Cstr(Replace(CoGx.".Item("point_on_fuel_surface\Gy") Set pointz = parameters1." & pointx & ".")) pointx = Cstr(Replace(pointx.Item("point_on_fuel_surface\Gz") ratio." & sWord(2) & "." & Volume & ". THIS TIME IN SMALLER PIECES -----------------------------------If (i-0.Item("inertia_fuel\Gz") Set pointx = parameters1.Item("inertia_fuel\Gx") Set CoGy = parameters1.Item("point_on_fuel_surface\Gx") Set pointy = parameters1. ". ".Value. ".")) pointz = Cstr(Replace(pointz.Value.Number <> 0 Then Set Volume = Nothing Set CoGx= Nothing 64 .".5 +(StepSize/2) To 1 step StepSize Set Volume = parameters1.Value. "." & sWord(1) & ".Else '-------.Value.Write (sWord(0) & ".IF AN ERROR IS DETECTED ALL VALUES ARE SET TO NOTHING AND YOU 'CAN DECIDE WHAT TO WRITE IN THE RESULT ------------------------------------------------If Err. ".IF THE NUMBER OF CUTS ARE FEW IT MEANS THAT THERE IS A BIG 'DIFFERENCE IN VOLUME BETWEEN TWO CUTS."." & CoGx & ".Item("inertia_fuel\Volume") Set CoGx = parameters1. ". SO THE VOLUME IS BEING CUT 'ONCE MORE.")) CoGz = Cstr(Replace(CoGz.")) ostream. ". ". "." & pointz & Chr(10)) End If On Error GOTO 0 Next 'ERRORS ARE ENABLED '--------.")) CoGy = Cstr(Replace(CoGy.Value. "."." & pointy & ".Item("inertia_fuel\Gy") Set CoGz = parameters1.Update '-----------.THE VALUES FROM THE MEASURES ARE CHANGED INTO A TEXT WITH A ".".Value = k On Error Resume Next 'DISABLES ALL ERRORS part1." & CoGy & ".Value.5)/(StepSize) < (1/StepSize)/4 Then For k = 0." 'AS DELIMITER AND IS WRITEN TO THE RESULT FILE --------------------------------Volume = Cstr(Replace(Volume. ".". ". ". "."." & CoGz & ".")) pointy = Cstr(Replace(pointy.

" & pointy & ". "." & sWord(2) & ".Value.")) CoGy = Cstr(Replace(CoGy." & "-99" & ". ".Write (sWord(0) & "." & CoGy & ". ".".IF THE CENTER OF GRAVITY IS ZERO THE VOLUME IS ALSO ZERO AND 'WE HAVE MOVED OUTSIDE THE TANK AND THE FOR-LOOP IS ABORTED -------------Elseif CoGx.Value.".")) CoGx = Cstr(Replace(CoGx." & "-99" & ".")) pointz = Cstr(Replace(pointz. ". ".")) ostream.THE VALUES FROM THE MEASURES ARE CHANGED INTO A TEXT WITH A ".Value = "0" And CoGz."." & pointx & ".Set CoGy = Nothing Set CoGz= Nothing Set pointx = Nothing Set pointy = Nothing Set pointz = Nothing ostream.".Value = "0" And CoGy.".Value. "." & CoGz & "."." & CoGx & ".Value." & pointz & Chr(10)) End If On Error GOTO 0 Next Else End If wend 'ERRORS ARE ENABLED Stream. ". ".")) CoGz = Cstr(Replace(CoGz.Value = "0" Then Exit For '---------." & "-99" & ". "." & Volume & ".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 FOR-LOOP IS ABORTED ---------------------------------------------------Elseif (volume_ref." & "-99" & ".Value." & sWord(1) & ".")) pointy = Cstr(Replace(pointy.Write ("-99" & "." & "-99" & ".Value) < 0.00000001 Then Exit For Else '-------.Close ostream.". "." & "-99" & ". ".Value ." 'AS DELIMITER AND IS WRITEN TO THE RESULT FILE --------------------------------Volume = Cstr(Replace(Volume. ".")) pointx = Cstr(Replace(pointx.Value.Close msgBox("The analysis was done " & now) WAS FINISHED End Sub 'TELLS THE USER WHEN THE ANALYSIS 65 ." & "-99" & Chr(10)) 'WHAT TO WRITE IN THE RESULT '----------. "." & "-99" & ".Volume." & "-99" & ". ".Value.

CenterPoints. WeightsX = W1.OutPutScaling.Appendix 8.PreScaling. PreScalingX = k_i1.mat file in the current directory.mat CenterPointsZ WeightsZ PreScalingZ OutPutScalingZ -APPEND end end 66 . switch PointType case {'PointOnSurface'} for i = 8:10 [W1. save PointOnSurface.Weights. X_c1. WeightsZ = W1. %the results. PreScalingY = k_i1. rbf (MATLAB function) function [W1 X_c1] = rbf(D. PreScalingZ = k_i1. M] = rbf_calc(D.mat CenterPointsY WeightsY PreScalingY OutPutScalingY -APPEND end if i == 10 % z-coordinat CenterPointsZ = X_c1. %D = is the result file from CATIA containing the orientation of the %fuel acceleration vector. %PointType = choose between PointOnSurface or CenterOfGravity depending %on the coordinates of interest.mat CenterPointsX WeightsX PreScalingX OutPutScalingX MaxVolume -V4 end if i == 9 % y-coordinat CenterPointsY = X_c1. volumes and point coordinates %(the file has to be imported into Matlab using file-Import Data). WeightsY = W1.PointType) %this is the main function for the radial basis function approximation. OutPutScalingZ = L. if i == 8 % x-coordinat CenterPointsX = X_c1. OutPutScalingX = L.MaxVolume %is saved to a . save PointOnSurface. MaxVolume = M.i). k_i1. save PointOnSurface. L. OutPutScalingY = L.

k_i1. WeightsY = W1. OutPutScalingY = L.i).mat CenterPointsZ WeightsZ PreScalingZ OutPutScalingZ -APPEND end end otherwise error('unknown PointType') end 67 . save CenterOfGravity. PreScalingX = k_i1.mat CenterPointsY WeightsY PreScalingY OutPutScalingY -APPEND end if i == 7 % z-coordinat CenterPointsZ = X_c1. save CenterOfGravity. PreScalingZ = k_i1. OutPutScalingZ = L. WeightsZ = W1. PreScalingY = k_i1.case {'CenterOfGravity'} for i = 5:7 [W1. save CenterOfGravity. OutPutScalingX = L. WeightsX = W1.mat CenterPointsX WeightsX PreScalingX OutPutScalingX -V4 end if i == 6 % y-coordinat CenterPointsY = X_c1. if i == 5 % x-coordinat CenterPointsX = X_c1. X_c1. L] = rbf_calc(D.

The tolerance.Py.1:4). first weight factor is set to zero. rbf_calc (MATLAB function) function [W1. %Max volume X = [D(:. M] = rbf_calc(D. %Observe that the corresponding data point might influence results as %there will be no rbf centra at that point k_i(1)=0.i). k_i1.Appendix 9. k_i1. %this is a prescaler for Gaussian RBF % to include a constant term.N_c]=size(D). I=find(D(:. P_min=min(P). k_i=1*ones(N_r.k_i.%Which point component to calculate Px. X_c1. L. %the average residual between the training points and the calculated %ones are set by err.1.1:4). 68 . %removes false values from the data set by sorting out the volumes which are -99 D=D(I.X(:. used for selecting centres.CoGy or CoGz P_max=max(P).1:4) P].tol). [N_r.4)~=-99). [W1. err = 4. is %calculated based on the err and the scale factor used for the current %coordinate. L=(P_max-P_min).1).X(:.Pz. X_c1. P=D(:.i) %prepares the data and performs the calculation for the selected point %and its three coordinates. %mm tol = (err^2)*N_r/L^2.4)). P=P/L.CoGx.5). err1] = divide_data(X(:.:). %scales the vector to the length 1 M=max(D(:.

k_i).Xc(1:floor(end/2).:). The process is influenced by the fast Fourier %transform (FFT) algorithm.Y(ceil(end/2):end.err1]= train_rbf(X(1:floor(end/2). which then are being trained by %the function train_rbf.Y(1:floor(end/2).X_c12]. :).Xc(ceil(end/2):en d. %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.:). X_c1.k_i12]. %all constants [W1. k_i11.W12].'select'. k_i1.:). k_i1.Appendix 10.%recursive call with half of the data [W12. err1]= divide_data(X(1:floor(end/2).tol).tol) %divides the data into smaller parts.k_i11.'select'.tol). k_i).:). X_c1. k_i.Y(ceil(end/2):end.tol). err1]= divide_data(X(ceil(end/2):end. k_i12.W12]. %picks the best centras and weights from all the subsets end 69 . X_c11.Xc(ceil(end/2):end. k_i1=[k_i11. err1]=divide_data(X.X_c12].:).Xc. X_c12.k_i1.Y. X_c11.Xc(1:floor(end/2).Y(1:floor(end/2)).:). err1]= train_rbf(X(ceil(end/2):end.Xc. to include a constant term if length(X)/2<1000 [W11. W1=[W11. divide_data (MATLAB function) function [W1. k_i12.k_i12].:).Y. %picks the best points from the first half of the train data [W12.:).:). [W1. X_c1.'select'. k_i1.k_i. %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.Y. %the picked centre points from the two halves W1=[W11. X_c12.k_i.tol). err1]=train_rbf(X.:).k_i1.'select'. %the picked weights from the two halves k_i1=[k_i11. err1]=train_rbf(X.Xc.%recursive call with the other half Xc=[X_c11.

k_i).k_i.%weight matrix [xx. %Xcin = matrix with all possible RBF centres %k_i = a prescaler for Gaussian RBF. k_o=k_i. orientations of the fuel acceleration %vector and the volumes.tol) %trains a radial basis function and selects the RBF centres.1).Xcin.1). P]=sim_rbf(Xcin. indices=1:N.1).X. %z = vector with output training data.N+1).W. PTP=zeros(N. If 'preset' all points will be %used as %RBF centres. N=size(Xcin.X.W. errtot=eye(1.%number of centres W=zeros(N.1).%find weights Xc=Xcin.Appendix 11.1).centra. err=(z-phi*W)'*(z-phi*W).%simulate rbf clear xx znorm=z'*z. ind=1. if the option centra='select' is %chosen. R=eye(N). %X = matrix with training data. %this is done in order to get the tolerance equal to the sum of squared errors obtained for the training points 70 . phi]=sim_rbf(Xcin. epsilon=1e-15. 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. g=zeros(N. train_rbf (MATLAB function) function [W Xc k_o err]=train_rbf(X. the point component.k_i). else M=length(z).1). indstop=N.z. %centra may be 'preset' or 'select'. if strcmp(centra.%simulate rbf clear xx W=phi\z. W=zeros(N.%weight matrix [xx.'preset') N=size(Xcin.

%Modified Gram-Schmidt factorization of P with resorting and stopping %criteria, see "Chen, S. et al. (1989) Orthogonal least squares methods %and their application to non-linear 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+k-1; perm=[1:k-1 ind k:ind-1 ind+1:N]; P=P(:,perm); g=g(perm); R(1:k-1,:)=R(1:k-1,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=z-g(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 ACC-VECTORS 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

Limitation = 1 hybridBody1.AddNewSphere(reference2. 45. reference1.ShapeFactory Set intersect1 = shapeFactory1.Surface = reference4 part1.000000. -45.000000.ShapeFactory Set reference3 = part1.CHECK IF THE SPHERE INTERSECT WITH THE TANK -----------------------Set body2 = bodies1.CreateReferenceFromName("") Set closeSurface1 = shapeFactory1.Bodies Set body1 = bodies1.CreateReferenceFromObject(hybridShapePointCoord1) Set hybridShapeFactory1 = part1.AppendHybridShape hybridShapePointCoord1 part1.Update '------------------------.Set axisSystem1 = axisSystems1. D/2.000000.CREATES A SPHERE AROUND THE POINT WITH THE DIAMETER OF THE PORT --------D = 1 'DIAMETER OF THE PORT (mm) Set reference2 = part1.CreateReferenceFromObject(hybridShapeSphere1) closeSurface1.AppendHybridShape hybridShapeSphere1 part1.RefAxisSystem = reference1 hybridBody1.InWorkObject = body2 Set shapeFactory1 = part1.Add() part1.AddNewCloseSurface(reference3) Set reference4 = part1.Update '--------. 0.Update '------------------------.CreateReferenceFromObject(axisSystem1) hybridShapePointCoord1.MAKES THE SPHERE TO A SOLID BODY ----------------------------------------------Set bodies1 = part1. 180.InWorkObject = body1 Set shapeFactory1 = part1.Item("Absolute Axis System") Set reference1 = part1.HybridShapeFactory Set hybridShapeSphere1 = hybridShapeFactory1.Item("PartBody") part1.000000) hybridShapeSphere1.AddNewIntersect(body1) 74 .

Delete wend Stream." + CSTR(Y) + "." + CSTR(Z) + ")" ' IF THE PORT IS WITHIN THE TANK On Error Resume Next part1.name = "Port" + "(" + CSTR(X) + ".Add intersect1 selection1." + CSTR(Z) + ") is outside the tank" End if selection1.body1." + CSTR(Y) + ".Close msgBox("It is done") End Sub 75 .Number <> 0 Then ' THE PORT DOES NOT INTERSECT WITH THE TANK body1.Update If Err.name = "Port" + "(" + CSTR(X) + ".

1) .1:3)].temp_M].1:3)== data(j+i. Max volume error (MATLAB function) function [E M O]=max_volume_error(data) %calculates the volume difference between all volume cuts. end end Vx=V(j:j+i-1.1)~=-99).I]= max(E) O(I. j=1. temp_E=max(X).:). temp_M=mean(X). M = [M. 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.j+1.1:3) Mm = mean(M) 76 . j=j+i. I=find(data(:. end [Em. end E = [E. i =1. E=[].Appendix 14.4). O=[]. while j < size(V.temp_E]. %removes false values from the data data=data(I. if i == left break. left = size(V.1) j. for i = 2:size(Vx. Vx=sort(Vx). M=[].1).1:3))==3 i = i+1. while sum(data(j.1) X(i-1)=abs(Vx(i)-Vx(i-1)). V=data(:.data(j.

Sign up to vote on this title
UsefulNot useful