"""Simple water flow example using ANUGA This program can be used to write some text and water it become covered by water! """ ######################THIS IS THE SECTION TO PUT YOUR TEXT INTO######################################################## letter_number = 5 #the number of letters in the text you wish to spell with water (include spaces as letters when counting) your_text = ['A','N','U','G','A'] #put your text in here following the format shown use 'space' to put in a space #--------------------------------------------------------------------------------------------------------------------------------------------------------------- ##########Parameters - These values are intended to be experimented with to produce different results########################################################### #--------------------------------------------------------------------------------------------------------------------------------------------------------------- depth = -50 #the elevation of the channel cut by the letters (negative number gives channels cutting into the surface, #positive gives peaks rising up from the surface). Channels generally look better. letter_height = 80 #the height of each letter letter_width = 80 #the width of each letter letter_thickness = 7 #the thickness of each letter slope = -0.1 #the slope of the surface (negative number gives a downslope, positive gives an upslope) inflow_amount = 25 #controls the volume of water which flows into the model outflow_amount = -50 #controls the volume of water which flows out of the model amplitude = 50 #amplitude of wave (wave height m) if you want to use a wave change a boundary to Bt period = 10 #wave period (sec) if you want to use a wave change a boundary to Bt left_boundary = 'Bi' #Sets up the boundary conditions for the model, Bt calls a wave input (use it to see a series of waves wash across the model) right_boundary = 'Bo' # Bi calls a constant inflow amount (defined above) while Bo calls a constant outflow amount top_boundary = 'Br' # Br causes any flow that contacts the boundary to be reflected back from it (the reflected flows momentum has equal magnitude but opposite direction to the incident flow) bottom_boundary = 'Br' simulation_speed = 1 #smaller number gives a slower, more precise simulation. #Very low numbers e.g. 0.1 will make the animation appear to run in slow motion simulation_length = 18*letter_number #the number of seconds that the simulation runs for #-------------------------------------------------------------------------------------------------------------------------------------------------------- ######################################################################################################################################################### #Please ensure that you understand what the program is doing and what you are changing before changing any of the values below this point################ ######################################################################################################################################################### #-------------------------------------------------------------------------------------------------------------------------------------------------------- # Standard modules import os import time import sys #------------------------------------------------------------------------------ # Import necessary modules #------------------------------------------------------------------------------ from anuga.abstract_2d_finite_volumes.mesh_factory import * from anuga.abstract_2d_finite_volumes.domain import * from anuga.shallow_water import * from anuga.shallow_water.shallow_water_domain import * from anuga.shallow_water.data_manager import * from math import * from numpy import * from numpy import sin, cos, pi #-------------------------------------------------------------------------------------------------------------------------------------------------------- # Setup computational domain #------------------------------------------------------------------------------ length = (letter_width)*(letter_number) +0.2*letter_width width = (letter_height)*1.3 dx = dy = 5 # Resolution: Length of subdivisions on both axes points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy), len1=length, len2=width) domain = Domain(points, vertices, boundary) domain.set_name('Spell_Your_Name_With_Water')# Output name domain.set_datadir('.') #store sww output here #------------------------------------------------------------------------------ # Setup initial conditions #------------------------------------------------------------------------------ def topography(x,y): """Complex topography defined by a function of vectors x and y.""" #general slope and buildings z = slope*x + 0.1*(cos(x)+cos(y))+ 5 return z #BUILD TOPOGRAPHY from functions defining letters (above)############################ domain.set_quantity('elevation', topography) # elevation is a function N = len(your_text) #the number of letters in the word to be spelt print "the length of the text is", N, "letters" print your_text for k in range(N): current_letter = your_text[k] #the letter that is currently being plotted print "the current letter is", current_letter #brute force approach def A(x,y): z = 0*x N = len(x) for i in range(N): ymin = ((letter_height)/((letter_width)/2))*(x[i]- (k)*letter_width) ymax = ((letter_height)/((letter_width)/2))*(x[i]- (k)*letter_width) + letter_thickness xmin = 0 xmax = 0.5*letter_width if ymin < y[i] < ymax and xmin + (k)*letter_width< x[i] < xmax+ (k)*letter_width: z[i] += depth for i in range(N): ymin = ((-letter_height)/((letter_width)/2))*(x[i]-(0.5*letter_width+ (k)*letter_width)) + letter_height ymax = ((-letter_height)/((letter_width)/2))*(x[i]-(0.5*letter_width+ (k)*letter_width)) + letter_height + letter_thickness xmin = 0.5*letter_width xmax = letter_width if ymin < y[i] < ymax and xmin + (k)*letter_width< x[i] < xmax+ (k)*letter_width: z[i] += depth for i in range(N): ymin = letter_height/2 - 0.5*letter_thickness ymax = letter_height/2 + 0.5*letter_thickness xmin = (letter_height/2)/((letter_height)/((letter_width)/2)) xmax = ((letter_height/2)- letter_height)/((-letter_height)/((letter_width)/2)) + 0.5*letter_width if ymin < y[i] < ymax and xmin + (k)*letter_width< x[i] < xmax+ (k)*letter_width: z[i] += depth return z def B(x,y): z = 0*x N = len(x) for i in range(N): ymin = 0 ymax = letter_height xmin = 0.5*letter_thickness xmax = 2*letter_thickness if ymin < y[i] < ymax and xmin + (k+0.05)*letter_width< x[i] < xmax+ (k+0.05)*letter_width: z[i] += depth for i in range(N): if (x[i]-((letter_width/2)-10+ (k+0.05)*letter_width))**2+(y[i]-(0.25*letter_height))**2<((letter_height/4))**2 and letter_thickness + (k+0.05)*letter_width< x[i]: z[i] += depth if (x[i]-((letter_width/2)-10+ (k-0.05)*letter_width))**2+(y[i]-(0.25*letter_height))**2<(((letter_height/4)-0.6*letter_thickness))**2 and letter_thickness + (k-0.1)*letter_width< x[i]: z[i] += -1*depth if (x[i]-((letter_width/2)-10+ (k+0.05)*letter_width))**2+(y[i]-(0.75*letter_height))**2<((letter_height/4))**2 and letter_thickness + (k+0.05)*letter_width< x[i]: z[i] += depth if (x[i]-((letter_width/2)-10+ (k-0.05)*letter_width))**2+(y[i]-(0.75*letter_height))**2<(((letter_height/4)-0.6*letter_thickness))**2 and letter_thickness + (k-0.1)*letter_width< x[i]: z[i] += -1*depth for i in range(N): ymin = (letter_height/2)-5 ymax = (letter_height/2)+5 xmin = 0.5*letter_thickness xmax = 0.3*letter_width if ymin < y[i] < ymax and xmin+ (k+0.05)*letter_width < x[i] < xmax+ (k+0.05)*letter_width: z[i] += depth return z def C(x,y): z = 0*x N = len(x) for i in range(N): if (x[i]-(letter_width/2 + (k)*letter_width))**2+(y[i]-(letter_height/2))**2<(0.9*(letter_height/2))**2 and 0 + (k)*letter_width < x[i] < 0.80*letter_width + (k)*letter_width: z[i] += depth if (x[i]-(letter_width/2 + (k)*letter_width))**2+(y[i]-(letter_height/2))**2<(0.9*((letter_height/2)-letter_thickness))**2 and 0 + (k)*letter_width < x[i] < 0.80*letter_width + (k)*letter_width: z[i] += -1*depth return z def D(x,y): z = 0*x N = len(x) for i in range(N): ymin = 0 ymax = letter_height xmin = 0.5*letter_thickness xmax = 3*letter_thickness if ymin < y[i] < ymax and xmin + (k)*letter_width < x[i] < xmax + (k)*letter_width: z[i] += depth if (x[i]-((letter_width/2)+ (k)*letter_width))**2+(y[i]-(letter_height/2))**2<(0.9*(letter_height/2))**2 and 1.9*letter_thickness + (k)*letter_width < x[i] : z[i] += depth if (x[i]-((letter_width/2)+ (k-0.15)*letter_width))**2+(y[i]-(letter_height/2))**2<(0.9*((letter_height/2)-1.3*letter_thickness))**2 and 1.9*letter_thickness + (k)*letter_width < x[i]: z[i] += -1*depth return z def E(x,y): z = 0*x N = len(x) for i in range(N): if 0 < y[i] < letter_height and 0.5*letter_thickness + (k)*letter_width < x[i] < 2*letter_thickness+ (k)*letter_width: z[i] += depth if (1-0.01*letter_thickness)*letter_height < y[i] < letter_height and 1.9*letter_thickness + (k)*letter_width < x[i] < 0.8*letter_width+ (k)*letter_width: z[i] += depth if (0.5-0.005*letter_thickness)*letter_height < y[i] < (0.5+0.005*letter_thickness)*letter_height and 1.9*letter_thickness + (k)*letter_width< x[i] < 0.8*letter_width+ (k)*letter_width: z[i] += depth if 0 < y[i] < 0.01*letter_thickness*letter_height and 1.9*letter_thickness + (k)*letter_width< x[i] < 0.8*letter_width+ (k)*letter_width: z[i] += depth return z def F(x,y): z = 0*x N = len(x) for i in range(N): if 0 < y[i] < letter_height and 0.5*letter_thickness + (k)*letter_width< x[i] < 2*letter_thickness+ (k)*letter_width: z[i] += depth if (1-0.01*letter_thickness)*letter_height < y[i] < letter_height and 1.9*letter_thickness + (k)*letter_width< x[i] < 0.8*letter_width+ (k)*letter_width: z[i] += depth if (0.5-0.005*letter_thickness)*letter_height < y[i] < (0.5+0.005*letter_thickness)*letter_height and 1.9*letter_thickness + (k)*letter_width< x[i] < 0.8*letter_width+ (k)*letter_width: z[i] += depth return z def G(x,y): z = 0*x N = len(x) for i in range(N): if (x[i]-(letter_width/2+ (k)*letter_width))**2+(y[i]-(letter_height/2))**2<(0.9*(letter_height/2))**2 and 0 + (k)*letter_width< x[i] < 0.80*letter_width+ (k)*letter_width: z[i] += depth if (x[i]-(letter_width/2+ (k)*letter_width))**2+(y[i]-(letter_height/2))**2<(0.9*((letter_height/2)-letter_thickness))**2 and 0 + (k)*letter_width< x[i] < 0.80*letter_width+ (k)*letter_width: z[i] += -1*depth if (0.4-0.005*letter_thickness)*letter_height < y[i] < (0.4+0.005*letter_thickness)*letter_height and 0.5*letter_width + (k)*letter_width< x[i] < 0.95*letter_width+ (k)*letter_width: z[i] += depth if 0 < y[i] < 0.4*letter_height and (0.8-0.01*letter_thickness)*letter_width + (k)*letter_width< x[i] < 0.8*letter_width+ (k)*letter_width: z[i] += depth return z def H(x,y): z = 0*x N = len(x) for i in range(N): if 0 < y[i] < letter_height and 0.5*letter_thickness + (k)*letter_width< x[i] < 2*letter_thickness+ (k)*letter_width: z[i] += depth if 0 < y[i] < letter_height and (letter_width - 2*letter_thickness) + (k)*letter_width< x[i] < (letter_width -0.5*letter_thickness)+ (k)*letter_width: z[i] += depth if (0.5-0.005*letter_thickness)*letter_height < y[i] < (0.5+0.005*letter_thickness)*letter_height and 1.9*letter_thickness + (k)*letter_width< x[i] < (letter_width-1.9*letter_thickness)+ (k)*letter_width: z[i] += depth return z def I(x,y): z = 0*x N = len(x) for i in range(N): if 0 < y[i] < letter_height and (0.5-0.01*letter_thickness)*letter_width + (k)*letter_width< x[i] < (0.5+0.01*letter_thickness)*letter_width+ (k)*letter_width: z[i] += depth if (letter_height - 0.85*letter_thickness) < y[i] < letter_height and 0.3*letter_width + (k)*letter_width< x[i] < 0.7*letter_width+ (k)*letter_width: z[i] += depth if 0 < y[i] < 0.85*letter_thickness and 0.3*letter_width + (k)*letter_width< x[i] < 0.7*letter_width+ (k)*letter_width: z[i] += depth return z def J(x,y): z = 0*x N = len(x) for i in range(N): if y[i]< -(((0.9*(letter_height/2))**2 - (x[i]- (0.5*letter_width+ (k)*letter_width))**2)**0.5)+ 0.6*letter_height and 0