Write a function interpolate1ddatatarg where data is a list


EXERCISE- HYDROSTATIC AND STABILITY CALCULATOR

This exercise will use the Bonjean curves to determine the hydrostatics of a ship at any required draught. As discussed last week the Bonjean curves are a powerful way of expressing sectional area data with respect to the baseline of the ship. This provides a curve of area with respect to draught. A full set of these curves for an entire vessel can be very useful for the calculation of a ships hydrostatics at varying conditions or attitudes. Take for example a ship sitting on a wave, Figure 1.

Knowing the draught at every station and using the Bonjean curves, the area at each station can be found. With this information the immersed volume of the ship and the position of the centre of buoyancy can be calculated using numerical integration. The results of which can determine whether the vessel will heave upwards or downwards and trim bow down or bow up.

Figure 1 Ship on a wave

This exercise will interpolate the Bonjean data for a target draught, essentially providing the sectional area of the ship. As an example, in order to get the volumetric displacement of the ship at the target waterline, we will then conduct a numerical integration of the sectional area data.

This process of numerical integration can be used to calculate all the required hydrostatics as outlined below.

ASSIGNMENT

Create a file named ex2_[student number].py. Import the contents from the week 1 exercises using the command:

Import ex1_[student number] as ex1

The objective of this assignment is to write the tools required to create a dictionary of hydrostatics.

The process will be broken down into stages. Your assignment is to write the following functions and include them in the file ex2_[student number].py: As you will see there are examples that use the functions developed in Exercise 1. If you are confident in the correctness of these functions then import your file using: import [student number]_ex1 as ex1. However, if you are not confident then I have included my functions on blackboard for you to import using: import Boyd_ex1 as ex1. Download Boyd_ex1.pyc and place this in your working folder.

? Write a function interpolate_1D(data,targ) where data is a list of tuples representing x and y data and targ is the target value of y. The function should return the interpolated value of x.

This function must not allow for extrapolation but return:

? the largest available x value if the target is higher than the largest value of z in data and

? zero if the target is lower than the smallest value of z in data

? Write a function trap_area(xdata, ydata) where xdata and ydata are lists of coordinates representing a curve. The function should return the area under the ydata with respect to the xdata, as a float, using the trapezium rule.

? Write a function trap_area(xdata, ydata) where xdata and ydata are lists of coordinates representing a curve. The function should return the area under the ydata with respect to the xdata, as a float, using the trapezium rule.

Where A(x) is the Bonjean area at any given section to a given waterline. The function given in equation (1) is integrated between A/2 and -A/2 where A is the length of the ship between AP and FP, i.e. A = 0 is amidships.

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: Write a function interpolate1ddatatarg where data is a list
Reference No:- TGS02192289

Expected delivery within 24 Hours