/[escript]/trunk/doc/cookbook/example07.tex
ViewVC logotype

Diff of /trunk/doc/cookbook/example07.tex

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3370 by ahallam, Sun Nov 21 23:22:25 2010 UTC revision 3373 by ahallam, Tue Nov 23 00:29:07 2010 UTC
# Line 26  The acoustic wave equation is defined as Line 26  The acoustic wave equation is defined as
26  where $p$ is the pressure, $t$ is the time and $c$ is the wave velocity. In this  where $p$ is the pressure, $t$ is the time and $c$ is the wave velocity. In this
27  chapter the acoustic wave equation is demonstrated. Important steps include the  chapter the acoustic wave equation is demonstrated. Important steps include the
28  translation of the Laplacian $\nabla^2$ to the \esc general form, the stiff  translation of the Laplacian $\nabla^2$ to the \esc general form, the stiff
29  equation stability criterion and solving for the displacement of acceleration solution.  equation stability criterion and solving for the displacement or acceleration solution.
30    
31  \section{The Laplacian in \esc}  \section{The Laplacian in \esc}
32  The Laplacian operator which can be written as $\Delta$ or $\nabla^2$  is  The Laplacian operator which can be written as $\Delta$ or $\nabla^2$,  is
33  calculated via the divergence of the gradient of the object, which in this  calculated via the divergence of the gradient of the object, which in this
34  example is the scalar $p$. Thus we can write;  example is the scalar $p$. Thus we can write;
35  \begin{equation}  \begin{equation}
# Line 70  _{1}$ would return; Line 70  _{1}$ would return;
70  \end{equation}  \end{equation}
71    
72  \autoref{eqn:grad} corresponds to the Linear PDE general form value  \autoref{eqn:grad} corresponds to the Linear PDE general form value
73  $X$. Notice however that the general form contains the term $X  $X$. Notice however, that the general form contains the term $X
74  _{i,j}$\footnote{This is the first derivative in the $j^{th}$  _{i,j}$\footnote{This is the first derivative in the $j^{th}$
75  direction for the $i^{th}$ component of the solution.},  direction for the $i^{th}$ component of the solution.},
76  hence for a rank 0 object there is no need to do more then calculate the  hence for a rank 0 object there is no need to do more then calculate the
77  gradient and submit it to the solver. In the case of the rank 1 or greater  gradient and submit it to the solver. In the case of the rank 1 or greater
78  object, it is necessary to calculate the trace also. This is the sum of the  object, it is also necessary to calculate the trace. This is the sum of the
79  diagonal in \autoref{eqn:gradrank1}.  diagonal in \autoref{eqn:gradrank1}.
80    
81  Thus when solving for equations containing the Laplacian one of two things must  Thus when solving for equations containing the Laplacian one of two things must
# Line 103  command will return the rank of the PDE Line 103  command will return the rank of the PDE
103  \section{Numerical Solution Stability} \label{sec:nsstab}  \section{Numerical Solution Stability} \label{sec:nsstab}
104  Unfortunately, the wave equation belongs to a class of equations called  Unfortunately, the wave equation belongs to a class of equations called
105  \textbf{stiff} PDEs. These types of equations can be difficult to solve  \textbf{stiff} PDEs. These types of equations can be difficult to solve
106  numerically as they tend to oscillate about the exact solution which can  numerically as they tend to oscillate about the exact solution, which can
107  eventually lead to a catastrophic failure. To counter this problem, explicitly  eventually lead to a catastrophic failure. To counter this problem, explicitly
108  stable schemes like the backwards Euler method and correct parameterisation of  stable schemes like the backwards Euler method, and correct parameterisation of
109  the problem are required.  the problem are required.
110    
111  There are two variables which must be considered for  There are two variables which must be considered for
# Line 132  $f_{s}$, or; Line 132  $f_{s}$, or;
132  \end{equation}  \end{equation}
133  For example a 50Hz signal will require a sampling rate greater then 100Hz or  For example a 50Hz signal will require a sampling rate greater then 100Hz or
134  one sample every 0.01 seconds. The wave equation relies on a spatial frequency,  one sample every 0.01 seconds. The wave equation relies on a spatial frequency,
135  thus the sampling theorem in this case applies to the solution mesh spacing. In  thus the sampling theorem in this case applies to the solution mesh spacing.
136  this way, the frequency content of the input signal directly affects the time  This relationship confirms that the frequency content of the input signal
137  discretisation of the problem.    directly affects the time discretisation of the problem.
138    
139  To accurately model the wave equation with high resolutions and velocities  To accurately model the wave equation with high resolutions and velocities
140  means that very fine spatial and time discretisation is necessary for most  means that very fine spatial and time discretisation is necessary for most
# Line 228  for i in range(ndx/2-ndx/10,ndx/2+ndx/10 Line 228  for i in range(ndx/2-ndx/10,ndx/2+ndx/10
228  We then submit the output to \verb!Locator! and finally return the appropriate  We then submit the output to \verb!Locator! and finally return the appropriate
229  values using the \verb!getValue! function.  values using the \verb!getValue! function.
230  \begin{python}  \begin{python}
231   src=Locator(mydomain,src_cut)  src=Locator(mydomain,src_cut)
232  src_cut=src.getValue(u)  src_cut=src.getValue(u)
233  \end{python}  \end{python}
234  It is then a trivial task to plot and save the output using \mpl  It is then a trivial task to plot and save the output using \mpl
235  (\autoref{fig:cxsource}).  (\autoref{fig:cxsource}).
236  \begin{python}  \begin{python}
237   pl.plot(cut_loc,src_cut)  pl.plot(cut_loc,src_cut)
238  pl.axis([xc[0]-src_radius*3,xc[0]+src_radius*3,0.,2*U0])  pl.axis([xc[0]-src_radius*3,xc[0]+src_radius*3,0.,2*U0])
239  pl.savefig(os.path.join(savepath,"source_line.png"))  pl.savefig(os.path.join(savepath,"source_line.png"))
240  \end{python}  \end{python}
# Line 272  the \verb!Locator! function. Line 272  the \verb!Locator! function.
272  \section{Acceleration Solution}  \section{Acceleration Solution}
273  \sslist{example07b.py}  \sslist{example07b.py}
274    
275  An alternative method is to solve for the acceleration $\frac{\partial ^2  An alternative method to the displacement solution, is to solve for the
276  p}{\partial t^2}$ directly, and derive the displacement solution from the  acceleration $\frac{\partial ^2 p}{\partial t^2}$ directly. The displacement can
277  PDE solution. \autoref{eqn:waveu} is thus modified;  then be derived from the acceleration after a solution has been calculated
278    The acceleration is given by a modified form of \autoref{eqn:waveu};
279  \begin{equation}  \begin{equation}
280    \nabla ^2 p - \frac{1}{c^2} a = 0    \nabla ^2 p - \frac{1}{c^2} a = 0
281  \label{eqn:wavea}  \label{eqn:wavea}
# Line 309  It is now prudent to investigate the sta Line 310  It is now prudent to investigate the sta
310  First, we let the frequency content of the source be very small. If we define  First, we let the frequency content of the source be very small. If we define
311  the source as a cosine input, then the wavlength of the input is equal to the  the source as a cosine input, then the wavlength of the input is equal to the
312  radius of the source. Let this value be 5 meters. Now, if the maximum velocity  radius of the source. Let this value be 5 meters. Now, if the maximum velocity
313  of the model is $c=380.0ms^{-1}$ then the source  of the model is $c=380.0ms^{-1}$, then the source
314  frequency is $f_{r} = \frac{380.0}{5} = 76.0 Hz$. This is a worst case  frequency is $f_{r} = \frac{380.0}{5} = 76.0 Hz$. This is a worst case
315  scenario with a small source and the models maximum velocity.  scenario with a small source and the models maximum velocity.
316    
# Line 340  the propagation requirement. For a maxim Line 341  the propagation requirement. For a maxim
341    \Delta t \leq \frac{1000.0m}{800} \frac{1}{380.0} = 0.0032s    \Delta t \leq \frac{1000.0m}{800} \frac{1}{380.0} = 0.0032s
342   \end{equation}   \end{equation}
343  \end{subequations}  \end{subequations}
344  We can see, that for each doubling of the number of nodes in the mesh, we halve  Observe that for each doubling of the number of nodes in the mesh, we halve
345  the timestep. To illustrate the impact this has, consider our model. If the  the time step. To illustrate the impact this has, consider our model. If the
346  source is placed at the center, it is $500m$ from the nearest boundary. With a  source is placed at the center, it is $500m$ from the nearest boundary. With a
347  velocity of $380.0ms^{-1}$ it will take $\approx1.3s$ for the wavefront to  velocity of $380.0ms^{-1}$ it will take $\approx1.3s$ for the wavefront to
348  reach that boundary. In each case, this equates to $100$,  $200$ and $400$ time  reach that boundary. In each case, this equates to $100$,  $200$ and $400$ time
349  steps. This is again, only a best case scenario, for true stability these time  steps. This is again, only a best case scenario, for true stability these time
350  values may need to be halved and possibly havled again.  values may need to be halved and possibly halved again.
351    
352  \begin{figure}[ht]  \begin{figure}[ht]
353  \centering  \centering
354  \subfigure[Undersampled Example]{  \subfigure[Undersampled Example]{
355  \includegraphics[width=3in]{figures/ex07usamp.png}  \includegraphics[width=0.45\textwidth,trim=0cm 6cm 5cm 6cm
356    ,clip]{figures/ex07usamp.png}
357  \label{fig:ex07usamp}  \label{fig:ex07usamp}
358  }  }
359  \subfigure[Just sampled Example]{  \subfigure[Just sampled Example]{
360  \includegraphics[width=3in]{figures/ex07jsamp.png}  \includegraphics[width=0.45\textwidth,trim=0cm 6cm 5cm 6cm
361    ,clip]{figures/ex07jsamp.png}
362  \label{fig:ex07jsamp}  \label{fig:ex07jsamp}
363  }  }
364  \subfigure[Over sampled Example]{  \subfigure[Over sampled Example]{
365  \includegraphics[width=3in]{figures/ex07nsamp.png}  \includegraphics[width=0.45\textwidth,trim=0cm 6cm 5cm 6cm
366    ,clip]{figures/ex07nsamp.png}
367  \label{fig:ex07nsamp}  \label{fig:ex07nsamp}
368  }  }
 \label{fig:ex07sampth}  
369  \caption{Sampling Theorem example for stability  \caption{Sampling Theorem example for stability
370  investigation.}  investigation.}
371    \label{fig:ex07sampth}
372  \end{figure}  \end{figure}
373    
374    

Legend:
Removed from v.3370  
changed lines
  Added in v.3373

  ViewVC Help
Powered by ViewVC 1.1.26