 |
>
#So you want to solve the wave equation, aye? Well, you will really need to use
#the matlab programs I have written and documented in matlab_sample.txt.
#However, the final plotting is all done right here in maple. I guess the first
#thing you might want to do is create a random function here in maple which
#you would then want to send to matlab. Here's how...
>
read "everything.txt":
>
T:=gasket(7): #define the gasket out to V7...
sym_func(T,7,.5,10); #defines a function out to V7 using .5 as a value
#and puts it into function slot 10 (see sym_func in functions.mws for a full
#description);
#Now, let's subtract .5 from all the points in function 10 (This makes the
#function 0 on the boundaries...
vm7:=vertices(7):
for i from 1 to nops(vm7) do
T[vm7[i],10]:=T[vm7[i],10]-.5 od:
>
#In order to get the spline basis representation of this function, we need the
#grammian matrix.
#First, let's define a spline basis out to V3...
vm:=vertices(3):
S:=gasket(3):
make_neighbors(S,3,vm):
>
#Get the grammian...
G:=evalf(eval(gen_iprod_matrix(S,3,vm))):
>
#take the inverse...
Ginv:=inverse(G):
>
#Now, let's get the spline representation...
calc_biharms(T,R,7,20); #need the biharmonic spline basis in 20...
outvec:=express_in_basis(T,Ginv,S,3,7,10,20):
>
#and now write that vector to a file...
write_vec("outvec.dat",outvec,81); #as in 81 elements...
>
#So now this vector can be read quite easily in matlab just by saying
#load outvec.dat
#As for solving the wave equation and saving the results, see my documentation
#in matlab_sample.txt. Once you have saved the output matrix, you can read it
#in and start making animations as follows...
>
#First, read in the data file as follows...
myvals:=read_basis_vals("/tahoe/home/raj/wave_time3.dat",81): #81 elts of V3...
>
#myvals is now a list of lists. More specifically, each myvals[i] is a
#representation of a function in the spline basis. In order to actually make
#the animation, you must run calc_biharms, as well as make_points. We have
#already run calc_biharms; I'll run make_points now...
>
make_points(T,7);
>
#So let's generate the output animation structure. The 15 is the function
#number which we will use to store each frame of the animation. 3 refers to
#the V3 spline basis, while 6 refers to calculating each function out to V6.
#As usual, the 20 is the biharmonic basis element storage location...
myplots:=make_animation(T,3,6,myvals,15,20):
>
#Instead of displaying on the screen, we'll send the output to an
#animated gif file. You can use netscape or some such thing to view it...
plotsetup(gif,plotoutput=`test.gif`,plotoptions="height=300,width=300");
>
#And now, let's plot it. After this command is run, you can view the file.
display(myplots,insequence=true,axes=NORMAL);
#To look at a scaled version, try
#display(myplots,insequence=true,axes=NORMAL,view=-.0005.. .0005);
>
#Now, let's say we wanted to look at the values of the same function along the
#line connecting 02 and 12...
myplots:=make_animation_line(T,3,6,myvals,15,20,[0,2],3,1,1/2):
#The extra numbers on the end are as follows: the [0,2] means the line
#starting from 02. The 3 means that the first neighbor along the line is the
#3rd neighbor, and the 1 means all subsequent neighbors are 1 neighbors (For
#a more complete explanation, see the documentation of this function in
#SG.mws). The 1/2 means that the length of the line is 1/2.
>
>
plotsetup(window); #Let's look at this in maple...
>
display(myplots,insequence=true,view=[0..1/2,-1 .. 1]);
|