LISOUSI: Line Source Simulation
fcsingleforce.cc
Go to the documentation of this file.
1 
37 #define TF_FCSINGLEFORCE_CC_VERSION \
38  "TF_FCSINGLEFORCE_CC V1.0 "
39 
40 #include "lisousi.h"
41 #include "functions.h"
42 
46 TFourier::Tspectrum zfpointfc(const int& n, const double& dt,
47  const double& offset,
48  const double& vs,
49  const double& vp,
50  const bool& debug)
51 {
52  TFourier::Tseries gPN(0,n-1);
53  const double tp=offset/vp;
54  const double ts=offset/vs;
55 
56  TFXX_debug(debug, "zfpointfc", "go..."
57  << " " << TFXX_value(n)
58  << " " << TFXX_value(vp)
59  << " " << TFXX_value(vs)
60  << " " << TFXX_value(offset)
61  << " " << TFXX_value(dt)
62  << " " << TFXX_value(tp)
63  << " " << TFXX_value(ts)
64  );
65 
66  // prepare near-field response
67  for (int i=0; i<n; ++i)
68  {
69  double t=i*dt;
70  if ((tp <= t) && (t >= ts))
71  {
72  gPN(i)=-t/(offset*offset*offset);
73  }
74  else
75  {
76  gPN(i)=0.;
77  }
78  }
79  TFXX_debug(debug, "zfpointfc", "Fourier Transformation");
80  TFourier::Tspectrum FCgPN=Fourier(gPN, dt);
81 
82  TFourier::Tspectrum retval(FCgPN.shape());
83 
84  TFXX_debug(debug, "zfpointfc", "total field "
85  << TFXX_value(retval.l()) << " "
86  << TFXX_value(FCgPN.l()));
87  const double df=1./(n*dt);
88  // prepare total response
89  for (int i=FCgPN.f(); i<=FCgPN.l(); ++i)
90  {
91  double f=(i-FCgPN.f())*df;
92  // far-field
93  retval(i) = exp(-IME*2.*M_PI*f*ts)/(offset*vs*vs);
94  TFXX_debug(debug, "zfpointfc",
95  TFXX_value(i) << " " <<
96  TFXX_value(f) << " " <<
97  TFXX_value(abs(retval(i))/abs(FCgPN(i))));
98  // near-field
99  retval(i) += FCgPN(i);
100  }
101 
102  TFXX_debug(debug, "zfpointfc", "finished");
103  return(retval);
104 }
105 
106 /*----------------------------------------------------------------------*/
107 
111 inline
112 double sqrtfct(const double& psample, const double& v)
113 {
114  double retval;
115  double arg=(v*v*psample*psample)-1.;
116  TFXX_assert(arg>=0., "negative argument of sqrt: "
117  "programming error - check source code!");
118  retval=sqrt(arg)/v;
119  return (retval);
120 }
121 
122 /*----------------------------------------------------------------------*/
123 
127 TFourier::Tspectrum zflinefc(const int& n, const double& dt,
128  const double& offset,
129  const double& vs,
130  const double& vp,
131  const bool& debug)
132 {
133  TFourier::Tseries gLN(0,n-1);
134  const double tp=offset/vp;
135  const double ts=offset/vs;
136 
137  // prepare near-field response
138  for (int i=0; i<n; ++i)
139  {
140  double t=i*dt;
141  if (t >= tp)
142  {
143  gLN(i) = sqrtfct(t/offset,vp);
144  if (t>=ts)
145  {
146  gLN(i) -= sqrtfct(t/offset,vs);
147  }
148  gLN(i) *= (-2./offset);
149  }
150  else
151  {
152  gLN(i)=0.;
153  }
154  }
155  TFourier::Tspectrum FCgLN=Fourier(gLN, dt);
156 
157  TFourier::Tspectrum retval(FCgLN.shape());
158 
159  const double df=1./(n*dt);
160  // prepare total response
161  for (int i=FCgLN.f(); i<=FCgLN.l(); ++i)
162  {
163  double f=(i-FCgLN.f())*df;
164  // far-field
165  retval(i) = -IME*M_PI*hankel(ts*2.*M_PI*f)/(vs*vs);
166  TFXX_debug(debug, "zflinefc",
167  TFXX_value(i) << " " <<
168  TFXX_value(f) << " " <<
169  TFXX_value(abs(retval(i))/abs(FCgLN(i))));
170  // near-field
171  retval(i) += FCgLN(i);
172  }
173  return(retval);
174 }
175 
176 /* ----- END OF fcsingleforce.cc ----- */
Ttimeseries::Tseries Tseries
Definition: lisousi.h:71
prototypes and structs for lisousi (prototypes)
const TFourier::Tcoeff IME
Definition: lisousi.h:85
TFourier::Tspectrum zfpointfc(const int &n, const double &dt, const double &offset, const double &vs, const double &vp, const bool &debug)
TFourier::Tspectrum zflinefc(const int &n, const double &dt, const double &offset, const double &vs, const double &vp, const bool &debug)
TFourier Fourier
Definition: globaldata.cc:44
TFourier::Tcoeff hankel(const double &arg)
Definition: hankel.cc:41
lisousi functions (prototypes)
double sqrtfct(const double &psample, const double &v)