Calculate the derivative of the cost

Assignment Help MATLAB Programming
Reference no: EM131317744 , Length:

QUESTION 1

Background

You have been asked to manage a project to install a pipeline from an offshore gas platform to an onshore gas processing plant, and to find the cheapest design that is possible. The platform is Q km offshore, and D km along the coastline from the processing plant. The pipeline will follow a straight line from the platform to the shore, and hit land at a point that is a distance ‘x' from that point on the shore that is closest to the platform. We assume that the coastline is a straight line. The layout is shown schematically in Fig 1.

339_Figure.jpg

Fig 1 A schematic of the gas pipeline from an offshore platform to an onshore processing facility.

Q1a

Company A has quoted the cost of laying the subsea part of the pipeline at $PSA per km (regardless of water depth) and the cost of laying onshore pipeline at $POA per km. Write a MATLAB function called CostA that calculates the total cost of laying the pipeline as a function of ‘x', the distances D and Q and the cost factors $ PSA and $ POA. Note: write the function so that ‘x' can be a vector - assume all other input parameters are scalars.

If Q = 50km, D = 100, PSA = $3.0M per kilometer and POA = $1.85M, plot the cost of the pipeline (in units of $100M) for 0 <= x <= 100km for 101 equally spaced points.

Q1b

Write a MATLAB function called dCostAdx that calculates the derivative of the cost with respect to the distance x. On a new figure, plot the derivative of cost w.r.t. x for 0 <= x <= 100km for 101 equally spaced points. Assume the same parameters from Q1a.

Use the Modified secant method to determine the distance ‘x' that gives the lowest cost pipeline. Print the lowest cost (in $M) to the MATLAB command window to 3 decimal places with a suitable statement attached (i.e. DO NOT just write the cost). On a new line print the distance ‘x' (in km - it might not be a whole number) where the cost is lowest (again to 3 decimal places with a suitable statement). In your fprintf statements, include units.

(NOTES:
1. This is a minimization problem.
2. You should write your own modified secant code.
3. You should use a starting guess in modified secant of 20.0
4. You should use an absolute precision of 0.001 (i.e., not a % precision)
5. You CANNOT easily pass a function that has multiple input parameters into another function as an input parameter. However, if you know all of the input values except x (i.e. you know Q, D, PSA , POA) you can define an anonymous function that you can pass as an input parameter

As an example, if x is a vector of values, and MyFunc a function with 4 parameters (x,A,B,C) then you cannot do the following
plot(x,MyFunc(x,A,B,C))
However, if you set values for A, B, C, then you CAN do this A=val1
B=val2; C=val3;
f=@(x) MyFunc(x,A,B,C)
plot(x,f(x))
NOTE: Every time you change one of the values (A, B or C), then you must redefine the anonymous function

Q1c

Keeping D, PSA and POA fixed as in Q1a (i.e. D = 100, PSA = $3.0M and POA = $1.85M), vary Q over the range 1 <= Q <= 75 km (in increments of 1 km). In a new figure, with two vertically stacked sub-plots, plot the optimal value of ‘x' for each value of Q in the top subplot. In the second subplot below the first, plot the total cost (in units of $100M) as a function of Q.

Q1d

Company B has also given a quote, where the cost of laying the onshore pipeline is fixed at $POB per km and the cost per kilometre of the subsea pipeline depends on the water depth η (also specified in kilometres). The cost per kilometer is

PS = PSB (1 + αη).

Consider the case where the depth of the water in kilometres (η) increases linearly with distance (in kilometres) from the shore (y) like
η (y) = εy

In this case, it is possible to calculate that the TOTAL cost of the subsea portion of this pipeline is

Costss = PSB(1 + 0.5αεQ)(√(x2 + (1 + ε2)Q2)

Write a function (called CostB) that calculates the TOTAL cost of the pipeline from Company B as a function of ‘x', the distances D and Q, cost factors PSB and POB, the slope factor ε and the depth-cost factor α.

If you assume the following parameters
• D=100km
• Q=50km
• PSB = $2.1M/km
• POB = $1.5M/km
• α = 0.5
• ε = 0.05

In a new figure, plot the cost of the pipeline for 0 <= x <= 100km for 101 equally spaced points. ADD your plot from part 1a for comparison and add a legend to the figure. You will see the two curves cross at one value of x.

Q1e

Find the distance ‘x' at which company A and company B's quotes are equal. Check your answer is correct by calculating the cost using both Pipe Cost models and make sure they are the same. Print the distance (in km) and cost from both Companies (in $M) to the command window, accurate to 3 decimal places only (new line for each number/value you print).

NOTE: You must do this numerically, NOT visually. You will need to re-frame this question as a root finding problem. You can use fzero to find the root, or any other root finding method you like.

Q1f

You have just received an environmental report that shows that a reef is situated between the platform and the shore. This reef is the home of a rare species of red-lipped guppy and you are told that the only place you are allowed to bring the pipeline ashore is at a location given by x=65km. At this location the quote from Company B is more expensive.

You begin negotiating with Company B to drop their price. They refuse to change the cost per kilometer for the onshore section (i.e. POB = $1.5M/km) because they will subcontract this to another party. However you believe they might be prepared to change the cost per kilometer of the subsea section. The depth factor, α, is not negotiable, but the factor PSB might be. Currently they have quoted PSB = $2.1M/km. Find the value they need to drop PSB to in order to be competitive with Company A's quote for pipe landfall at x = 65km.

YOU MUST find this value automatically in MATLAB, not by trial and error. Again, you should frame this question as a root finding problem, and again you may use any root finding method you like (including fzero).

Print the competitive PSB value to the MATLAB command window (in $M/km to 3 decimal places).

Question 2

Background

A residence time distribution (or RTD) is a probability density function that describes how long fluid stays in a continuous flow chemical reactor. One way of measuring an RTD is to inject a small pulse of a chemical tracer (e.g. salt, radioactive material or coloured dye) at the inflow of the rector and then measure the signal at the outflow of the reactor.

At one extreme is a so-called "plug-flow" reactor which has no mixing and in which all of the input pulse of tracer exits the reactor at the same time. Provided there is no short-circuiting, this time is given (in seconds) as

τ= V/Q

where V is the volume of the reactor (in m3) and Q is the flow rate (in m3s-1).

At the other extreme, a Continuously stirred tank reactor (CSTR) is one in which each element of fluid that is injected into the reactor is instantly uniformly mixed with everything else inside the reactor. The RTD for a CSTR is a negative exponential function.

Both of these extremes are idealised concepts and can never be realised in practice. In the real world, the RTD (usually) rises quickly, and then decays slowly, and in this question we investigate some different RTD's.

Q2a

You have been asked to determine if several different reactors are operating with similar behaviour, but you have not been given any information on their size, or design and have only been given a set of concentration measurements as a function of time, one for each reactor.

First you must open the rtd data file (‘rtd.dat') and read it into MATLAB using importdata. The first column of data is the time of the measurement (in seconds), and the other columns are the concentration measurements (C(t)) of the tracer at the exit of the reactor for an unknown number of reactors. Determine how many different reactors have been included in the file and print this number to the command window.

Plot each of the concentration versus time curves on the same figure using a different coloured line (in order, use as many as needed of black, red, green, blue, magenta, yellow). Ensure your plot has a legend using the text headers contained in the file.

Q2b

In order to compare the curves, they must be normalized. The normalized RTD curve (often called E(t)) is defined as

E(t) = C(t)/0∫C(t)dt

Write a function called CompTrap that calculates the integral of a function using the Composite Trapezoidal rule. The input parameters are a vector of (evenly spaced) times over the time range [t1, t2] and a vector of function values that corresponds to the time vector (you can assume that spacing of the data is uniform - you do not need to confirm this).

Normalise each of your concentration curves to give E(t) and in a new figure, plot these for each reactor using the same colours from part a. (NOTE: Instead of integrating to t = ∞ you should integrate to the last point in the data that you read in). Write the normalising value of 0∫C(t)dt for each reactor to the command window, one to a line.

Q2c

The mean residence time in the reactor can be determined from the following integral

τM = 0tE(t)dt

The mean residence time is also known as the "first moment" of the RTD. Higher order moments are also important and can be used to categorise and compare different reactors.

The second order moment is called the variance of the distribution and is

σ2 = 0(t - τM)E(t)dt

It can be normalized by the mean residence time to provide a value that indicates how big the standard deviation is compared to the mean:

σN = √1/τ2M0(t - τM)2E(t)dt = (1/τM)√σ2

The third order moment is called the skewness of the distribution and is

s3 = 1/σ3/20(t-τM)3E(t)dt

Calculate τM, σN and s3 (i.e. equation 1, 2, 3) for each of the reactors using your CompTrap function. Print them to the command window in tabular form using fprintf (DO NOT USE THE MATLAB table function). The output should looks like the table below

Reactor

Mean RT

StDev_N

Skewness

1

 

 

 

2

 

 

 

etc.

 

 

 

If two reactors have similar values of both σN and s3 they are operating in a similar way, even if their mean residence times are quite different (for example, they might be the same design but have different sizes and different flow rates). For the purposes of this question, we will assume that two reactors are similar if their values of σN do not differ from each other by more than 10% AND if their s3 also vary from each other by less than 10%.

Based on the results in your table, automatically calculate if any two reactors are similar and print a sentence to the command window for each pair that are, saying which pair. If reactors 1 and 2 are similar, make sure you do not also print that reactors 2 and 1 are similar.

Verified Expert

Solution is about estimation of the cost for various condition for a offshore processing plant. It used MATLAB functions for this calculations and uses run_all.m for all executions. Another part uses concentration for analysis and various parts are addressed in this case also. MATLAB is used in this scenario.

Reference no: EM131317744

Questions Cloud

Explain the nature of frequency shifting in each case : Identify the frequencies in the baseband, and the corresponding frequencies in the DSBSC, USB, and LSB spectra. Explain the nature of frequency shifting in each case.
Acquire in exchange : Assume that ¥87.04 equal $1. Also assume that 6.5614SKr equal $1. How many Japanese yen can you acquire in exchange for 4,300 Swedish krona?
Define and initialize tmp mains activation record : Define & initialize tmp main's activation record. When we write the contents of the stack, we write the contents of the whole stack, including previous activation records.
Describe the role of the financial institutions : Describe the role of the financial institutions and financial markets in our economy. Differentiate between primary and secondary markets. Differentiate between money and capital markets.
Calculate the derivative of the cost : MCD 4140: Computing for Engineers - You have been asked to manage a project to install a pipeline from an offshore gas platform to an onshore gas processing plant, and to find the cheapest design that is possible.
Taxes for the first year of project : The net working capital returns to its original level at the end of the project. The project is expected to generate annual sales of $550,000 and costs of $430,000. The tax rate is 35 percent and the required rate of return is 15 percent. What is ..
How do you find a vector perpendicular to a plane : What is the particular advantageous characteristic associated with the unit vectors in the Cartesian coordinate system?
Variance of the returns on rtf stock : RTF stock is expected to return 13 percent in a normal economy and lose 8 percent in a recession. The probability of a recession is 25 percent. What is the variance of the returns on RTF stock?
Compute the estimated tax liability on the differences : Compute the estimated tax liability on the differences between the estimated current value of the assets and liabilities and their tax bases.

Reviews

Write a Review

MATLAB Programming Questions & Answers

  Write a program that generates three random numbers

Write a program that generates three random numbers, each between 0 and 9. The three numbers are displayed and the message "You got Lucky Fours" will be displayed if at least two of the digits are 4.

  Control design using matlab

Control Design using Matlab,  Please try and explain the characteristic of all the plots and graphs.   Import all the required data in word of simply write in the script itself.

  Write commands to solve the system of equations

Write MATLAB commands to solve the system of equations. 7x-14y=95 -5x+9z=-50 -5x+15z=145

  What is gini index of income inequality

What is Φ (as function of θ)? Provide an analytical solution of Φ when θ = 3 and What happens to Gini index of income inequality as θ increases?

  Integration and random numbers

assemble 1,000 bolt + hole combinations. The bolts have a mean diameter of 1.000 cm, normally distributed with standard deviation of 0.010 cm. The holes have a mean diameter of 1.030 cm, normally distributed with standard deviation of 0.015 cm.

  Implement the steps outlined and carry out the simulation

Implement the steps outlined and carry out the simulation - Repeat the steps for the specifications - Also produce output waveforms for at least two carrier frequencies. attached document, and provide me with the matlab files for the requirement at..

  Write a matlab program to confirm that the ni versus t curve

Write a Matlab program to confirm that the ni versus T curve for Cie and Si graphed in Figure 220 can be generated by employing the empirical fit relationships below.

  Write a matlab program to analyze a patients ecg signal

Determine the Heart Rate of an ECG Recording of Unknown properties Using MATLAB - Write a MATLAB program to analyze a patient's ECG signal and provide warnings if the heart rate becomes either dangerously low or dangerously high.

  Write a program to test three edge detection algorithms

Write a program to test three edge detection algorithms (available in Matlab ) and one feature extraction algorithm (Harris). Students should try different parameters (if appropriate) and find the code that gives the best result for each image

  Write matlab scripts

Write MATLAB scripts for to accept two numbers from the user; Display all prime numbers between these two numbers.

  Design a three band stop filters

Design a three band stop filters for echo/reverberation cancellation for a specific room. Provide measurements of the room impulse response and frequency response with the coefficients.

  Use the matrix index number as the parameter for the x axis

Allow MATLAB® to use the matrix index number as the parameter for the x-axis. 5.3 Plot the following functions on the same graph for x values from - p to p, selecting spacing to create a smooth plot: y1 sin1x2 y2 sin1 2x2 y3 sin1 3x2

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd