Getting Started

Python Packages

This module requires the python packages: multiprocessing, matplotlib, numpy, math and numba which can be installed using pip from a terminal using

pip install multiprocessing matplotlib numpy math numba

Importing Codes

These codes can be run using the ALI_FMM class. The other module functions are used in this class and do not need calling directly. The class can be input using the command

from Anis_TTF_rays import ALI_FMM

with Anis_TTF_rays.py in the same directory.

Note

The folder __pycache__ stores some compiled functions. Functions requiring compiling will be slow to run initially if not already compiled.

Creating an instance of the ALI_FMM class

An instance of the class can be created using

Forward_Model = ALI_FMM(veln, velpn, vel_map, scx, scz)

The name of this instance can be whatever you want. See __init__() command for additional arguments.

Class functions can then be called using the instance variable. For example

Forward_Model.plot_phase(1)

This will plot the phase velocity of material with index 1 which is stored within Forward_Model. All functions must be called from an instance of the class except for generate_group_vel() and generate_phase_vel() which can also be called using

ALI_FMM.generate_group_vel(None, c_22, c_23, c_33, c_44, density)
ALI_FMM.generate_phase_vel(None, c_22, c_23, c_33, c_44, density)

Defining Materials

There are two ways in which materials can be defined for these codes. The first way is by using a table of velocity curves which can be input when the class instance is initialised. These variables can be accessed using Forward_Model.group_vel and Forward_Model.phase_vel. The group and phase velocities must both be input as a table with the first column being the angle from 0 to 360 in 1 deg increments, and other columns being the velocities for each material. If no argument is given, an isotropic material with a velocity of 1m/s is used. This can be used for all isotropic materials as the variable vel_map can be used to scale all velocities.

Example velocity table

Velocity table with a single material

0.0

5085.0026

1.0

5088.2812

2.0

5097.9530

3.0

5113.5586

4.0

5134.4274

5.0

5159.7804

6.0

5188.8210

7.0

5220.7981

8.0

5255.0399

9.0

5290.9659

10.0

5328.0849

11.0

5365.9866

12.0

5404.3296

13.0

5442.8306

14.0

5481.2538

15.0

5519.4023

16.0

5557.1106

17.0

5594.2389

18.0

5630.6681

19.0

5666.2964

20.0

5701.0359

21.0

5734.8104

22.0

5767.5531

23.0

5799.2058

24.0

5829.7167

25.0

5859.0401

26.0

5887.1352

27.0

5913.9657

28.0

5939.4989

29.0

5963.7055

30.0

5986.5592

31.0

6008.0363

32.0

6028.1154

33.0

6046.7773

34.0

6064.0048

35.0

6079.7826

36.0

6094.0969

37.0

6106.9356

38.0

6118.2881

39.0

6128.1450

40.0

6136.4986

41.0

6143.3422

42.0

6148.6704

43.0

6152.4793

44.0

6154.7657

45.0

6155.5281

46.0

6154.7657

47.0

6152.4793

48.0

6148.6704

49.0

6143.3422

50.0

6136.4986

51.0

6128.1450

52.0

6118.2881

53.0

6106.9356

54.0

6094.0969

55.0

6079.7826

56.0

6064.0048

57.0

6046.7773

58.0

6028.1154

59.0

6008.0363

60.0

5986.5592

61.0

5963.7055

62.0

5939.4989

63.0

5913.9657

64.0

5887.1352

65.0

5859.0401

66.0

5829.7167

67.0

5799.2058

68.0

5767.5531

69.0

5734.8104

70.0

5701.0359

71.0

5666.2964

72.0

5630.6681

73.0

5594.2389

74.0

5557.1106

75.0

5519.4023

76.0

5481.2538

77.0

5442.8306

78.0

5404.3296

79.0

5365.9866

80.0

5328.0849

81.0

5290.9659

82.0

5255.0399

83.0

5220.7981

84.0

5188.8210

85.0

5159.7804

86.0

5134.4274

87.0

5113.5586

88.0

5097.9530

89.0

5088.2812

90.0

5085.0026

91.0

5088.2812

92.0

5097.9530

93.0

5113.5586

94.0

5134.4274

95.0

5159.7804

96.0

5188.8210

97.0

5220.7981

98.0

5255.0399

99.0

5290.9659

100.0

5328.0849

101.0

5365.9866

102.0

5404.3296

103.0

5442.8306

104.0

5481.2538

105.0

5519.4023

106.0

5557.1106

107.0

5594.2389

108.0

5630.6681

109.0

5666.2964

110.0

5701.0359

111.0

5734.8104

112.0

5767.5531

113.0

5799.2058

114.0

5829.7167

115.0

5859.0401

116.0

5887.1352

117.0

5913.9657

118.0

5939.4989

119.0

5963.7055

120.0

5986.5592

121.0

6008.0363

122.0

6028.1154

123.0

6046.7773

124.0

6064.0048

125.0

6079.7826

126.0

6094.0969

127.0

6106.9356

128.0

6118.2881

129.0

6128.1450

130.0

6136.4986

131.0

6143.3422

132.0

6148.6704

133.0

6152.4793

134.0

6154.7657

135.0

6155.5281

136.0

6154.7657

137.0

6152.4793

138.0

6148.6704

139.0

6143.3422

140.0

6136.4986

141.0

6128.1450

142.0

6118.2881

143.0

6106.9356

144.0

6094.0969

145.0

6079.7826

146.0

6064.0048

147.0

6046.7773

148.0

6028.1154

149.0

6008.0363

150.0

5986.5592

151.0

5963.7055

152.0

5939.4989

153.0

5913.9657

154.0

5887.1352

155.0

5859.0401

156.0

5829.7167

157.0

5799.2058

158.0

5767.5531

159.0

5734.8104

160.0

5701.0359

161.0

5666.2964

162.0

5630.6681

163.0

5594.2389

164.0

5557.1106

165.0

5519.4023

166.0

5481.2538

167.0

5442.8306

168.0

5404.3296

169.0

5365.9866

170.0

5328.0849

171.0

5290.9659

172.0

5255.0399

173.0

5220.7981

174.0

5188.8210

175.0

5159.7804

176.0

5134.4274

177.0

5113.5586

178.0

5097.9530

179.0

5088.2812

180.0

5085.0026

181.0

5088.2812

182.0

5097.9530

183.0

5113.5586

184.0

5134.4274

185.0

5159.7804

186.0

5188.8210

187.0

5220.7981

188.0

5255.0399

189.0

5290.9659

190.0

5328.0849

191.0

5365.9866

192.0

5404.3296

193.0

5442.8306

194.0

5481.2538

195.0

5519.4023

196.0

5557.1106

197.0

5594.2389

198.0

5630.6681

199.0

5666.2964

200.0

5701.0359

201.0

5734.8104

202.0

5767.5531

203.0

5799.2058

204.0

5829.7167

205.0

5859.0401

206.0

5887.1352

207.0

5913.9657

208.0

5939.4989

209.0

5963.7055

210.0

5986.5592

211.0

6008.0363

212.0

6028.1154

213.0

6046.7773

214.0

6064.0048

215.0

6079.7826

216.0

6094.0969

217.0

6106.9356

218.0

6118.2881

219.0

6128.1450

220.0

6136.4986

221.0

6143.3422

222.0

6148.6704

223.0

6152.4793

224.0

6154.7657

225.0

6155.5281

226.0

6154.7657

227.0

6152.4793

228.0

6148.6704

229.0

6143.3422

230.0

6136.4986

231.0

6128.1450

232.0

6118.2881

233.0

6106.9356

234.0

6094.0969

235.0

6079.7826

236.0

6064.0048

237.0

6046.7773

238.0

6028.1154

239.0

6008.0363

240.0

5986.5592

241.0

5963.7055

242.0

5939.4989

243.0

5913.9657

244.0

5887.1352

245.0

5859.0401

246.0

5829.7167

247.0

5799.2058

248.0

5767.5531

249.0

5734.8104

250.0

5701.0359

251.0

5666.2964

252.0

5630.6681

253.0

5594.2389

254.0

5557.1106

255.0

5519.4023

256.0

5481.2538

257.0

5442.8306

258.0

5404.3296

259.0

5365.9866

260.0

5328.0849

261.0

5290.9659

262.0

5255.0399

263.0

5220.7981

264.0

5188.8210

265.0

5159.7804

266.0

5134.4274

267.0

5113.5586

268.0

5097.9530

269.0

5088.2812

270.0

5085.0026

271.0

5088.2812

272.0

5097.9530

273.0

5113.5586

274.0

5134.4274

275.0

5159.7804

276.0

5188.8210

277.0

5220.7981

278.0

5255.0399

279.0

5290.9659

280.0

5328.0849

281.0

5365.9866

282.0

5404.3296

283.0

5442.8306

284.0

5481.2538

285.0

5519.4023

286.0

5557.1106

287.0

5594.2389

288.0

5630.6681

289.0

5666.2964

290.0

5701.0359

291.0

5734.8104

292.0

5767.5531

293.0

5799.2058

294.0

5829.7167

295.0

5859.0401

296.0

5887.1352

297.0

5913.9657

298.0

5939.4989

299.0

5963.7055

300.0

5986.5592

301.0

6008.0363

302.0

6028.1154

303.0

6046.7773

304.0

6064.0048

305.0

6079.7826

306.0

6094.0969

307.0

6106.9356

308.0

6118.2881

309.0

6128.1450

310.0

6136.4986

311.0

6143.3422

312.0

6148.6704

313.0

6152.4793

314.0

6154.7657

315.0

6155.5281

316.0

6154.7657

317.0

6152.4793

318.0

6148.6704

319.0

6143.3422

320.0

6136.4986

321.0

6128.1450

322.0

6118.2881

323.0

6106.9356

324.0

6094.0969

325.0

6079.7826

326.0

6064.0048

327.0

6046.7773

328.0

6028.1154

329.0

6008.0363

330.0

5986.5592

331.0

5963.7055

332.0

5939.4989

333.0

5913.9657

334.0

5887.1352

335.0

5859.0401

336.0

5829.7167

337.0

5799.2058

338.0

5767.5531

339.0

5734.8104

340.0

5701.0359

341.0

5666.2964

342.0

5630.6681

343.0

5594.2389

344.0

5557.1106

345.0

5519.4023

346.0

5481.2538

347.0

5442.8306

348.0

5404.3296

349.0

5365.9866

350.0

5328.0849

351.0

5290.9659

352.0

5255.0399

353.0

5220.7981

354.0

5188.8210

355.0

5159.7804

356.0

5134.4274

357.0

5113.5586

358.0

5097.9530

359.0

5088.2812

360.0

5085.0026


Anisotropic materials can also be defined using a stifness tensor and density of the material. This is done using the add_materials() function which will generate a table of velocities. Alternatively for orthotropic materials, velocities can be calculated at run time using the parameter stif_den which has the stifness tensor and density at all grid points. All stifness tensors using this method must be input using MPa not Pa and have type np.int64, which is used to aviod overflow errors. Any points not using this method will not be used and so can be left as zeros.

Tip

Using stif_den is prefered for anisotropic materials as it gives more accurate velocities.

Assigning Materials

There are four variables which define the materials at each grid point.

  • veln is the anisotropic orientations at each grid point i.e rotation of the velocity curve.

  • velpn is the material index of each grid point, with 0 being a grid point where the velocity is calculated at run time using stif_den and others being the column in the velocity tables for that material.

  • vel_map is the velocity scaling of each grid point. This is often set to 1 for most anisotropic materials, however for isotropic materials this parameter defines the velocity at a grid point (when used with a material with velocity of 1 in tables of velocities).

  • stif_den is the stifness tensors and density at grid points which is only used when the material index is 0.

Calculating Traveltime Fields

Travel time fields can be calculated through three different functions:

  • update_i() calculates the travel time field for a single source.

  • update() calculates travel time fields for all sources unless specific ones are selected through the sources parameter.

  • update_parallel() is the same as update(), however parallelisation is used to speed up computation.

Calculating Ray Paths

Ray paths can be calculated using find_all_TTF_rays() or in parrallel using find_all_TTF_rays_parallel(). These functions will calculate the nessessary travel time fields and perform ray tracing through them. The parameter trans_pairs defines which source reciever pairs have ray paths calculated. If ray paths are saved into the class they can be retrieved using the ray_path() function.

Tip

Travel times of ray paths are identical when traveling forward or backwards along the ray. Swapping the source and receivers using the paramter trans_pairs so that less recievers are used will result in faster computation as less travel time fields are required.

Example

Both values of trans_pairs use the same source/receiver pairs, however using a single reciever with three sources is computationally cheaper than one source and three receivers

0

0

0

0

1

0

0

0

1

0

0

0

1

0

0

0

0

1

1

1

0

0

0

0

0

0

0

0

0

0

0

0