Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I recently replaced my hot water tank and needed to drain it through the tap on

ID: 3601041 • Letter: I

Question

I recently replaced my hot water tank and needed to drain it through the tap on the bottom so I could lift it out of the basement. Naturally, I calculated how long this would take before I started so I knew how much homework I could grade while waiting.

DrainingTank.png

If you drain a tank of water through a tap at the bottom, the flow is given by Bernoulli's equation, and if we make lots of assumptions (the tank isn't really tall, the tap diameter is a lot smaller than the tank diameter, water has no viscosity), then the velocity of the water coming out the tap is:

v_{tap}=sqrt{2g:cdot:hleft(t ight)}vtap=2gh(t)

where h(t) is the depth of the water in the tank as it drains and g is the acceleration due to gravity (9.81 m/s^2). This gives the velocity of the the water leaving the tank through the tap. Clearly, the velocity of the water flowing downward in the tank is slower because the tank has a larger diameter than the tap. Using conservation of mass, one can easily show that the product of velocities and cross-sectional areas is the same for the tank and the tap. Note that the velocity of water in the tank V_tank is the same as the rate of change of the water height, dh/dt. So we get

LaTeX: V_{tank}D^2 = v_{tank}{d^2} Longrightarrow
V_{tank} = rac{dh}{dt} = v_{tap} rac{d^2}{D^2}VtankD2=vtankd2Vtank=dhdt=vtapd2D2

Substituting from above, we get the differential equation:

rac{dh}{dt}=-sqrt{2g}left( rac{d^2}{D^2} ight)sqrt{hleft(t ight)}dhdt=2g(d2D2)h(t). (Eqn 1)

Assuming the tank is a cylinder, and D is constant, this is a separable equation, and has the solution

hleft(t ight):=:left[-sqrt{ rac{g}{2}}left( rac{d^2}{D^2} ight)t:+:sqrt{h_o} ight]^2h(t)=[g2(d2D2)t+ho]2. (Eqn 2)

Note that h(t=0) = h0 is the initial water depth, and h decreases as time increases.

This is fine for a perfect cylindrical tank, but the reason I needed to replace the water tank is that it was starting to bulge in the middle so that

LaTeX: Dleft(h ight):=:D_o+:Bleft(h ight)D(h)=Do+B(h), (Eqn 3)

in Eqn (1).  

Let's let the tank be H meters tall and model the bulge, B(h), as a catenary (cosh(x)) that gives B = 0 for h = 0 (bottom of the tank), increases to a maximum at the middle of the tank (h = H/2) of B=0.1*D0 and then decreases back to B=0 for h = H (top of tank). Create the matlab function that does this. (Hint: Start with
B = A*(cosh(1)-cosh((x/C-0.5)*2))/(cosh(1)-1)
and figure out what A and C need to be)

Question: Suppose the tank is 2 meters tall (H = 2), full to begin with (h=H), 1m in diameter at the top and bottom (D0 = 1), 1.1m in diameter at the bulge (D(1) = 1.1), and the diameter (d) of the tap is d=0.02m. If I assume the analytic solution eqn (2) for a cylindrical tank is correct (i.e. ignoring the bulge) and use that to calculate the time to drain, will it be completely empty? If not, how much water is left?

Solution Method

1) There are a couple different ways to create a matlab program to solve this problem. I'd like you to use a combination of ode45 to find the height of the water in the tank for a specified amount of time.

2) Use the analytic solution for a cylindrical tank to find the time (tanalytic) to drain the tank and use this to estimate how long to run the ode45 solution.

3) Use nested functions and define all the parameters of the problem at the top of the main function. Define the following nested functions:

a) The bulge function
function bulge = B(h)

If you code this first, you can plot it to figure out what A and C need to be to get the right form.

b) The diameter function, eqn (3), which calls a
function diameter = D(h)

c) The rate function in Eqn (1), which calls b
function hprime = f(t, h)

d) The analytic solution eqn (2)
function h = hanalytic(t)

4) In the main function

a) solve Eqn (1) using ODE45 and the rate function (3c above) for the time interval 0 to tanalytic

b) Plot the approximate analytic solution and the solution from ODE45 so you can compare which drains faster.

c) Print out whether there is water left in the tank after the ODE45 solution and how much.

Submit this as a single file. The file should contain the main driving function and all the additional nested functions at the bottom of file

Explanation / Answer

The van der Pol equation is a second order ODE

Solve the van der Pol equation with using ode45.
The function vdp1.m ships with MATLAB® and encodes the equations.
Specify a single output to return a structure containing information about the solution, such as the solver and evaluation points.

tspan = [0 20];
y0 = [2 0];
sol = ode45(@vdp1,tspan,y0)
sol = struct with fields:
solver: 'ode45'
extdata: [1x1 struct]
x: [1x60 double]
y: [2x60 double]
stats: [1x1 struct]
idata: [1x1 struct]

Use linspace to generate 250 points in the interval [0 20]. Evaluate the solution at these points using deval.

x = linspace(0,20,250);
y = deval(sol,x);
Plot the first component of the solution.

plot(x,y(1,:))

------------------------------------------------------------------------------------------------------
Print out whether there is water left in the tank after the ODE45 solution and how much.
Submit this as a single file. The file should contain the main driving function and all the additional nested functions at the bottom of file


Concurrent recording of electroencephalography (EEG) during transcranial magnetic stimulation (TMS) is an emerging and powerful tool for studying brain health and
function. Despite a growing interest in adaptation of TMS-EEG across neuroscience disciplines, its widespread utility is limited by signal processing challenges.
These

challenges arise due to the nature of TMS and the sensitivity of EEG to artifacts that often mask TMS-evoked potentials (TEP)s.
With an increase in the complexity
of data processing methods and a growing interest in multi-site data integration, analysis of TMS-EEG data requires the development of a standardized method to recover TEPs from various sources of artifacts. This article introduces TMSEEG, an open-source MATLAB application comprised of multiple algorithms organized to facilitate a step-by-step procedure for TMS-EEG signal processing. Using a modular design and interactive graphical user interface (GUI), this toolbox aims to streamline TMS-EEG signal processing for both novice and experienced users. Specifically, TMSEEG provides: (i) targeted removal of TMS-induced and general EEG artifacts; (ii) a step-by-step modular workflow with flexibility to modify existing algorithms and add customized algorithms; (iii) a comprehensive display and quantification of artifacts; (iv) quality control check points with visual feedback of TEPs throughout the data processing workflow; and (v) capability to label and store a database of artifacts. In addition to these features, the software architecture of TMSEEG ensures minimal user effort in initial setup and configuration of parameters for each processing step. This is partly accomplished through a close integration with EEGLAB, a widely used open-source toolbox for EEG signal processing. In this article, we introduce TMSEEG, validate its features and demonstrate its application in extracting TEPs across several single- and multi-pulse TMS protocols. As the first open-source GUI-based pipeline