Created
October 19, 2011 02:46
-
-
Save piti118/1297362 to your computer and use it in GitHub Desktop.
script to compare various boat placement strategies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
t_flow = 4000.#m^3/s total chaopraya flow | |
t_area = 4000.#m^2 total crossection of chaopraya | |
rho = 1000.#kg/m^3 water density | |
P_smallboat = 1000 | |
A_smallboat = 0.1 | |
#non interference | |
#P is power per boat (watts) | |
#A is effective area (m^3) | |
#n is number of boats in parallel | |
#return the addition in flow | |
def flowdiff(P,A,n,t_flow): | |
a_area = A #affected Area | |
a_flow = t_flow/t_area*A #flow in affected area | |
f_new = newflow_columate(P,A,a_flow) #new flow in affected area | |
#print 'f_new-a_flow',(f_new-a_flow) #flow generated per boat | |
un_flow = t_flow/t_area*(t_area-n*A)#unaffected flow | |
new_total = f_new*n+un_flow #new total flow | |
flow_diff = new_total - t_flow | |
return flow_diff | |
#calculate new flow given power area and initial flow | |
#in columated area | |
#f_old initial flow | |
#A effective area | |
#P power | |
def newflow_columate(P,A,f_old): | |
f_new = pow(f_old**3 + 2*P*A**2/rho,1./3.) | |
return f_new | |
#calculate new flow assuming faraway assumption | |
#(flow are distributed throughout when it gets through the second row) | |
def newflow_faraway(nboat,npara,P,A): | |
#assume nboat is divisible by nboat | |
nseries = nboat/npara #yep integer division | |
new_flow = t_flow | |
for i in xrange(nseries): | |
new_flow = new_flow + flowdiff(P,A,npara,new_flow) | |
return new_flow | |
#calculate new flow assuming short distance assumption | |
#(new flow is still columated when it gets to the second row) | |
def newflow_shortdistance(nboat,npara,P,A): | |
#assume nboat is divisible by npara | |
nseries = nboat/npara | |
unaffected_area = t_area-npara*A | |
initial_flow = t_flow*A/t_area#initial flow per column | |
#find new flow for each column | |
new_flow = initial_flow | |
for i in xrange(nseries): | |
new_flow = newflow_columate(P,A,new_flow) | |
total_new_flow = npara*new_flow #total new flow in all the affected area | |
return total_new_flow + unaffected_area/t_area*t_flow #add it back to unaffected area | |
def faraway_analysis(nboat,P,A): | |
print 'For faraway assumption' | |
print 'npara','nseries','totalnewflow' | |
for npara in xrange(1,nboat+1): | |
if nboat%npara==0: | |
totalflow = newflow_faraway(nboat,npara,P,A) | |
print (npara,nboat/npara,totalflow) | |
else: | |
pass | |
def shortdistance_analysis(nboat,P,A): | |
print 'For short distance assumption' | |
print 'npara','nseries','totalnewflow' | |
for npara in xrange(1,nboat+1): | |
if nboat%npara==0: | |
totalflow = newflow_shortdistance(nboat,npara,P,A) | |
print (npara,nboat/npara,totalflow) | |
else: | |
pass | |
def main(): | |
faraway_analysis(1000,P_smallboat,A_smallboat) | |
shortdistance_analysis(1000,P_smallboat,A_smallboat) | |
if __name__ == '__main__': | |
main() | |
#using estimated power and effective from K.Matipon | |
#print '1000 small boats non interference' | |
#print flowdiff(P=1000.,A=0.1,n=1000.,t_flow=t_flow) | |
#print '10 big ones non interference' | |
#print flowdiff(P=2000000.,A=1.,n=10.,t_flow=t_flow) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For faraway assumption | |
npara nseries totalnewflow | |
(1, 1000, 4174.006179381851) | |
(2, 500, 4174.008036625053) | |
(4, 250, 4174.011751293362) | |
(5, 200, 4174.013608718646) | |
(8, 125, 4174.019181358588) | |
(10, 100, 4174.022896755448) | |
(20, 50, 4174.04147738306) | |
(25, 40, 4174.05076997475) | |
(40, 25, 4174.078656866721) | |
(50, 20, 4174.097255729882) | |
(100, 10, 4174.190341401425) | |
(125, 8, 4174.23694142936) | |
(200, 5, 4174.376970953434) | |
(250, 4, 4174.470515731825) | |
(500, 2, 4174.940557782721) | |
(1000, 1, 4175.892417638112) | |
For short distance assumption | |
npara nseries totalnewflow | |
(1, 1000, 4002.6144628561347) | |
(2, 500, 4004.1090130042558) | |
(4, 250, 4006.4403597498963) | |
(5, 200, 4007.4376666218354) | |
(8, 125, 4010.0591179627927) | |
(10, 100, 4011.601310017484) | |
(20, 50, 4018.0066644456783) | |
(25, 40, 4020.7176101184396) | |
(40, 25, 4027.769172292149) | |
(50, 20, 4031.870989700814) | |
(100, 10, 4048.5776600265067) | |
(125, 8, 4055.501522817685) | |
(200, 5, 4073.1401901560766) | |
(250, 4, 4083.1687177730555) | |
(500, 2, 4122.410862019136) | |
(1000, 1, 4175.892417638112) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment