123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- /*
- 2D FDTD simulator
- Copyright (C) 2019 Emilia Blåsten
- This program is free software: you can redistribute it and/or
- modify it under the terms of the GNU Affero General Public License
- as published by the Free Software Foundation, either version 3 of
- the License, or (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
- You should have received a copy of the GNU Affero General Public
- License along with this program. If not, see
- <http://www.gnu.org/licenses/>.
- */
- /* ricker.c: Function to implement a Ricker wavelet. This is a
- * travelling-wave version of the function se ezInc() takes arguments
- * both in time and space. */
- #include "ezinc.h"
- #include "gridtmz.h"
- #include <math.h>
- #include <stdio.h>
- #include <stdlib.h>
- static double cdtds, ppw = 0;
- // initialize source-function variables
- void ezIncInit(Grid *g) {
- // printf("Enter the points per wavelength for Ricker source: ");
- // scanf(" %lf", &ppw);
- ppw = 30;
- cdtds = g->cdtds;
- return;
- }
- // caculate source function at given time and location
- double ezInc(double time, double location) {
- double arg;
- if(ppw <= 0) {
- fprintf(stderr,
- "ezInc: ezIncInit() must be called before ezInc.\n"
- " Points per wavelength must be positive.\n");
- exit(-1);
- }
- arg = M_PI * ((cdtds * time - location) / ppw - 1.0);
- arg = arg * arg;
- return (1.0 - 2.0*arg) * exp(-arg);
- }
|