Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Tutorial 3
Intrinsic functions

Learning goals

  1. Using data stored in objects.
  2. Using the LININT, DQUAD and LEASQ functions to interpolate in datasets.
  3. Using an object as a function.
  4. Using the INTEGR function to perform numerical integration.
  5. Using the LEASQ function
Prior knowledge

Interface

...


The solution Waterline containing the shape of the dimensionless waterline, has been created in tutorial 2. In order to store this data and use it for further operations, the contents will be placed in a new object within the object Ships.

 Image Modified In the class Geometry, create a new object called Hull. As we want to store static data in this object, make sure it is determined by Value from Object/Database (as described in tutorial 2). In the workbase, select the object Ships (underDataset). In the Knowledge Browser, right click the parameter Hull and select Parameter to Dataset (or drag it tot Ship). When you are asked how to add Hull to the Ships object, select the list and continue. The new object is now placed within Ships.

Let's add the content of the Waterline object in the Waterline solution to the object Hull.

...

Image Modified In the solution Waterline in the tree of the Workbase, select the Waterline object (so the tree node in the solution),  right click Image Modified in the table of the Workbase and select All to clipboard (or F4). Paste the data (both Frame and Rel_B) in the objectHull (answer Yest to all for including the parameters in the Hull object).

When you are done, you will have a Ships object containing data in a Hull object. The Hull object should be part of the Ships object because the Ships object is the database entry point. And because you want to use all Waterline data as one set, it should be in one Hull object (or as a TeLiTab value as an alternative).

...

The relative width Rel_B at every frame was calculated directly using the polynomial formula. In reality, the waterline of a ship will be defined more likely by a number of points than by a formula. To obtain the width at a certain location, you should interpolate between these points. We'll use the LININT() function to perform a linear integration.

...

Image Modified Add the following relation in Top Goals/Undefined:

Intpol_Rel_B=LININT(@Hull,2,@Frame,@Rel_B,Frame)

Make sure Intpol_Rel_B is dimensionless and determined by SYS: System/Equation.

...

  

The syntax of every intrinsic function in Quaestor is described in the wiki, see the functionsoverview. The syntax above means the following.

...

When Quaestor calculates this function, it determines the value Frame (which is user input). This value is then compared to the values of the given column for X (which is the column Frame of the object Hull), and an interpolated value for Rel_B with respect to the input Frame is assigned to the parameter Intpol_Rel_B. Notice that an @ is used to identify the data within the object.

 Image Modified Run a solution for Intpol_Rel_B using the process manager and selecting the ship object. Make sure that Intpol_Rel_B is in the class Top Goals/Undefined to see it in the Process Manager. The process manager is crucial here, as static data from theShips object should be used (which contains the object Hull). For frame, enter 3.20.

Quaestor should return 0.26 for Intpol_Rel_B.

To find out how accurate the interpolation is, we introduce an error. The interpolated parameter uses static data from the object Hull, but we also defined the relative width analytically (the parameter Rel_B). 

...

Image Modified Add the following relations to your Top Goals:

Error = Intpol_Rel_B - Rel_B

in which Error is a dimensionless SYS parameter. Run a solution for this parameter, Intpol_Rel_B will be calculated by Quaestor automatically because it is required by Error. Make sure you use the process manager to select the Ships object as dataset. For frame, enter 3.20 again.

The solution in two-digit format (-0.00) will be presented in the list of the Workbase. When you select this solution, more digits are shown in the Frame Viewer (figure 2a) or Explanation window (figure 2b). Note that you can change the number of decimal places presented in the Workbase by changing the value Decimal places in the Slots & Properties window. 

...

Figure 2b   In the Explanation window, more digits of the selected parameter are shown 

...

Image Modified Change the relation (find the relation and press F2) for Intpol_Rel_B  in

Intpol_Rel_B = DQUAD(@Hull, 2, @Frame, @Rel_B, Frame) 

which uses the same data, but now performs a quadratic interpolation. It's not necessary to initialize existing solutions. 

Editing relations was covered in tutorial 2. Remember that the use, syntax and examples of all quaestor functions are available in the wiki: functionsoverview.

 Image Modified Run a solution for Error again at the same frame.

The error now turns out to be zero. This makes sense, as DQUAD is a quadratic interpolation method and this waterline is defined by a quadratic function as well.

...


By numerical integration, the waterplane area can be calculated. Therefore, the dimensionless length and width should be transformed to the real length and width. For the width we can use the existing relation for B_Frame, for the length in meters we add a relation.

 Image Modified In the class Geometry, add the following relation

 X = Frame/20 * Lpp

Which is the position in meters along the longitudinal direction of the ship. By now you should know a proper dimension, reference and determined by value should be provided. 

To calculate the waterplane are for a certain ship, we would like Quaestor to integrate the width with respect to X. The dimensionless width table is already present in our object Hull, let's use it in the integration.

...

Image Modified In the Top Goals class, add the following relation

Waterplane_Area = INTEGR(Hull(@X, @B_Frame, Lpp, B), 2, @X, @B_Frame, 2, 0, Lpp) 

which is the waterplane area in square meters (m^2).

The syntax used may seem a bit confusing at first.

...

  • HULL(..) is the object from which data will be used, now containing the columns X and B_frame
  • 2 is the number of dimensions = always 2 using INTEGR.
  • @X refers to the column that will be used as the parameter X in the integration: X
  • @B_Frame refers to the column that will be used as the parameter Y in the integration: B_Frame
  • 2 is the mode of integration, either Riemann (0), Trapezium (1) or Simpson (2). The latter is chosen here.
  • X_from=0 and X_to=Lpp are the parameters between wich will be integrated.

    Image Modified Run a solution for the waterplane area, using the process manager. 

The waterplane area is calculated for every variation in length and breadth of the ship.

Image Modified In the solution tree, select the object Hull or open it as TeLiTab text (remember that F2 is the shortkey to open it as TeLiTab text).

The telitab of the object hull is visible now (figure 3). Because we solved a multiple case problem, the object has been used as function and reused for every case. Only the contents of the last case calculated remains in the object.

...

The initial stability (GM) of the ships can also be calculated using numerical integration.

 

...

Image Modified Add a new class, called Stability, as sub-class of Geometry. Note that a subclass is created by naming it Geometry.Stability. Add the following relation to this class:

         GM = KB + BM - KG

...

Distance between center of buoyancy B and metacenter M in meters:

BM = Moment_of_Inertia / (DISP * 1000/ Rho)

Moment of inertia of the waterplane area in m^4:

Moment_of_Inertia = 1/12 * INTEGR(Hull(@X, @B3_Frame, Lpp, B), 2, @X, @B3_Frame, 2, 0, Lpp)

Please note (and you might have experienced this in the previous tutorial too) that the parameter Moment_of_Inertia might still have a red cross and an Error warning in the knowledge base although you have provided the relation and a dimension. When this is the case, for sure you still have the Hull object in focus in a solution of the Workbase. When this is the case, Quaestor communicates that the relation you have provided cannot be used inside this object (and thus you have a red cross for Moment_of_Inertia). When you select a top node of a solution, you will see that the Moment_of_Inertia parameter is properly defined.

...

Note that the syntax of the moment of inertia relation is similar to that of the waterplane area relation.

Image Modified Run a solution for the initial stability GM of every possible ship, by selecting the ship object and GM as task in the process manager.

If the object Hull in the solution is now opened again, you'll see that the columns X and B3_frame are added to the object, whose values are calculated for every case of Frame and Rel_B within Hull. Note that the parameter B_Frame is also added, as it is used to calculate B3_Frame. See figure 4. Again, only the values of the last ship (last input case) are stored in the object.

...


Finaly, we'd like to compare the obtained values for GM to other ships. Data of the GM value for a certain ship length is available, so we only have to compare them. We'll use the least squares method to obtain an average GM value for a certain length, using the data of some other ships.

...

 Image Modified  Add the following new relation to your Top Goals:

GM_Check = LEASQ(TEXTITEM$(1), 2, "L", "GM", Lpp, 2) 

Enter the following text in the Data slot  in the Expression Editor of the relation GM_Check:

TEXTITEM1 =
|0
3 "ExampleShip" "L" "GM"
"1" 1 70 0.6
"2" 2 75 0.7
"3" 3 60 0.5
"4" 4 80 0.9
"5" 5 75 0.55
"6" 6 60 0.6
"7" 7 55 0.8
"8" 8 65 0.75
"9" 9 72 0.6 
"10" 10 80 0.56|

See figure 5. GM_Check is in meters. 

The LEASQ interpolation function now returns an average GM value in meters for a certain Lpp. The syntax TEXTITEM$(nr) is often used in Quaestor, and refers to a template, text item or TeLiTab in the Data slot of the Expression Editor. In this way, data that is not included in the knowledgebase but is only used in a particular function (as in our relation) can be used.

...

Figure 5   Including data in the relation by using textitems

 

        Run a solution using the Process Manager. Select Waterplane_AreaGM and GM_Check as goals. Note that you are able to select serveral goals at once...

...

To browse through results, it might be convenient to maximize the workbase window. Remember that you can always return to the default lay-out using the menu sequence Window->Standard. The result of the last solution is shown in figure 6.

 

 

Figure 6   Output of the solution, if the workbase window is maximized an inspection of the results is more easy 

...

You can verify your results by comparing it to [Tutorial 3 Finished]

<< Back to tutorial 2 -- Continue to tutorial 4 >>