# Demo entry 2780411

**Project1Functions**

Submitted by **anonymous**
on Sep 29, 2015 at 23:33

Language: Python. Code size: 1.7 kB.

# -*- coding: utf-8 -*- """ Created on Sat Sep 26 19:08:15 2015 @author: Dexter Antonio, Hayley Caddes, Chinedu Okorafor """ # A module of the functions that are used in the project. import numpy import math def convertVtoY(V,s): # this fuction takes a value of volume (V) and returns a heihgt of water (y) value return ((V*3.0*s**2.0)/(numpy.pi))**(1./3.) def convertYtoV(y,s): #this function takes a y value and converts it to a V value return y**3.0*numpy.pi/(3.0*s**2.0) def Qin(t): #takes time and outputs the inflow of water at that time return 3.5*(math.sin(t))**2.0 def Qout(y, Yout): #this is the function takes the height of the water and the output height and returns the outflow if y > Yout: return 3.2*(y-Yout)**1.4 else: return 0 #Eulers Method #takes t0 -initial time, f0-intial function value, the yout of the tank # diffeq is the right side of a differential equation, f(t), of the form df/dt = f(t) # delta T is the change in time and maxSteps is the number of steps def EulersMethod(t0,f0,yout,s,difEq,deltaT,maxSteps): timeArray = [] fArray = [] timeArray.append(t0) fArray.append(f0) for i in range(maxSteps+1): timeArray.append(deltaT+timeArray[i]) fArray.append(fArray[i]+difEq(timeArray[i],fArray[i],yout,s)*deltaT) return timeArray,fArray def diffEq(t ,V,yout,s): return Qin(t)-Qout(convertVtoY(V,s),yout) #this is the function that takes the ytop of the tank and the s value and returns #the surface area def surfacearea(s,ytop): h = ytop surfaceArea = (numpy.pi*h**2./(s**2.))*numpy.sqrt(1+s**2.) return surfaceArea

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.