Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup #98

Closed
wants to merge 293 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
293 commits
Select commit Hold shift + click to select a range
0ff25ea
Adding base examples
Olender Aug 11, 2022
1525be2
debugging
Olender Aug 12, 2022
6384d63
adding option for solver parameters
Olender Aug 16, 2022
844b744
adding output options
Olender Aug 16, 2022
5773a06
adding output options
Olender Aug 16, 2022
ad5a307
minor debugging
Olender Aug 16, 2022
735198f
Modev unpacking of parameters
Olender Aug 16, 2022
83643cf
debugging and fixing spelling
Olender Aug 17, 2022
35b01ac
clearing up imports
Olender Aug 17, 2022
f65b2ec
debugging and paralellism
Olender Aug 18, 2022
8e222d0
adding decorators for paralellism
Olender Aug 18, 2022
615f1a3
more options for debugging
Olender Aug 18, 2022
9ec01e0
debugging example case
Olender Aug 22, 2022
5faf0c4
just removing spaces
Olender Aug 22, 2022
8f9d0cd
debugging examples class
Olender Aug 22, 2022
edaa4b8
debugging examples
Olender Aug 22, 2022
e86c7c7
Moving to acoustic wave class
Olender Aug 24, 2022
4f0eea7
dg wave addition
Olender Aug 25, 2022
416e938
Merge branch 'wave_object' of https://github.com/Olender/spyro-1 into…
Olender Aug 25, 2022
e437bba
adding cut marmousi
Olender Aug 25, 2022
38b3b35
minor debugging
Olender Aug 30, 2022
3019cda
minor debugging
Olender Aug 31, 2022
9dadf74
debugging communicator
Olender Sep 12, 2022
f2a79f1
debugged comm
Olender Sep 13, 2022
11e1e0e
Adding analytical solution test
Olender Jun 15, 2023
f54d0a2
first source convergence analysis
Olender Jun 19, 2023
a8808db
going to quads
Olender Jun 19, 2023
5b00c0b
adding nodal sources
Olender Jun 20, 2023
6c6eab5
acoustic nodal object
Olender Jun 20, 2023
644620e
Files for image generation
Olender Jun 23, 2023
cfbae54
saving results in folders
Olender Jun 23, 2023
da629ec
propagation file
Olender Jun 23, 2023
7882af1
correctly naming
Olender Jun 23, 2023
e7fd75b
making wave class inherit parameter class
Olender Jun 23, 2023
ce9f63c
adding meshing package
Olender Jun 23, 2023
bced153
removing debugging text
Olender Jun 23, 2023
af8ed4f
adding documentation
Olender Jun 23, 2023
eb9eb11
trying out mms with heterogeneous c
Olender Jun 26, 2023
376dbd2
trying to debug
Olender Jun 26, 2023
9cd2996
debugging mms
Olender Jun 27, 2023
f2ef45f
debugging mms
Olender Jun 29, 2023
fac1f69
mms_working
Olender Jun 30, 2023
84e1428
working
Olender Jun 30, 2023
43c87a5
configuring figure
Olender Jul 1, 2023
1eb56a4
Naming functions
Olender Jul 3, 2023
d197be0
fixing graph
Olender Jul 3, 2023
d6b96e7
started moving files to folder
Olender Jul 3, 2023
48487fe
cleaning up
Olender Jul 3, 2023
3343473
getting next figure
Olender Jul 3, 2023
657a9b4
updating data
Olender Jul 3, 2023
d79182b
updating data
Olender Jul 3, 2023
20d202d
fixed MMS test
Olender Jul 3, 2023
eaddc15
fixed io test
Olender Jul 3, 2023
34247c5
fixed model paramters test
Olender Jul 3, 2023
b2fbf02
moving files
Olender Jul 4, 2023
0ddb3f8
cleaning up
Olender Jul 4, 2023
81d47b6
Adding 3D quads
Olender Jul 6, 2023
17a9de4
using tetrahedrals as base for hexa
Olender Jul 6, 2023
706629e
got 3d source and receiver point, tested in dof
Olender Jul 8, 2023
df709de
updating data
Olender Jul 10, 2023
60b0d74
added 3d mms
Olender Jul 10, 2023
496bbe7
updating data
Olender Jul 10, 2023
1931665
Merge branch 'source_injection_paper' of github.com:Olender/spyro-1 i…
Olender Jul 10, 2023
0fe7c32
image files
Olender Jul 10, 2023
7bc1ccf
moving chapter files
Olender Jul 10, 2023
b87d16c
fixing io call
Olender Jul 11, 2023
94abd30
fixed net at tests
Olender Jul 11, 2023
ae014e9
minor edit
Olender Jul 11, 2023
487faf2
fixed test
Olender Jul 11, 2023
05d67b2
fixing sources test
Olender Jul 11, 2023
3ee2acb
skipping tools for now
Olender Jul 11, 2023
9c3028f
adding time convergence test 2nd order CD
Olender Jul 11, 2023
6879b15
deleting thesis image files
Olender Jul 13, 2023
a47a323
Merge branch 'main' of github.com:Olender/spyro-1 into clean_up_sourc…
Olender Jul 13, 2023
cc89746
Merge pull request #1 from Olender/clean_up_source_injetion_branch
Olender Jul 13, 2023
92ee61e
minor debugging
Olender Jul 17, 2023
17874db
started adding gradient
Olender Jul 17, 2023
af37e09
temp fixes
Olender Jul 18, 2023
64b88fa
minor changes
Olender Jul 18, 2023
eaf8ffe
black formatting
Olender Jul 18, 2023
9a14ba2
MORE LINTING!
Olender Jul 18, 2023
ccb0f99
MORE LINTING!
Olender Jul 18, 2023
5c3e73b
FINISHED LINTING
Olender Jul 18, 2023
874ea12
minor debugging
Olender Jul 18, 2023
961689e
flake8 config
Olender Jul 18, 2023
9df342c
linting
Olender Jul 18, 2023
d1be1de
reducing code complexity
Olender Jul 19, 2023
9db8195
Merge branch 'adding_gradient' of github.com:Olender/spyro-1 into add…
Olender Jul 19, 2023
0c945ca
Started fixing problem with io
Olender Jul 20, 2023
ad8738d
switching to demeter
Olender Jul 20, 2023
a590b39
passing comm to mesh slows down
Olender Jul 21, 2023
3e8fa4e
fixing tests
Olender Jul 21, 2023
5112bb5
Merge pull request #4 from Olender/check_forward_and_cleanup_io
Olender Jul 21, 2023
56ef03b
cleanup
Olender Jul 21, 2023
77a13d8
Merge pull request #5 from Olender/temp_branch_to_test_code_scene_and…
Olender Jul 21, 2023
60951ae
Fixing readme and dependencies
Olender Jul 25, 2023
16cf7fc
fixing import
Olender Jul 25, 2023
9cd0aca
Merge pull request #6 from Olender/updating-readme
Olender Jul 25, 2023
65ef35e
moving meshing functions
Olender Jul 25, 2023
938aebf
Merge pull request #7 from Olender/reducing_code_complexity
Olender Jul 25, 2023
efb4f17
cleaning up and moving dictionary conversion
Olender Jul 25, 2023
998bfd4
fixing tests
Olender Jul 25, 2023
eab2bd6
Merge pull request #8 from Olender/reducing_code_complexity
Olender Jul 25, 2023
6d0f1cb
minor changes
Olender Jul 25, 2023
cc60f58
changed mesh sanity checks
Olender Jul 26, 2023
faed617
fixing tests
Olender Jul 26, 2023
9a6529f
fixing tests
Olender Jul 27, 2023
edd06bf
debugging and cleaning up
Olender Jul 27, 2023
52d38a1
Merge pull request #9 from Olender/reducing_code_complexity
Olender Jul 27, 2023
b52fef9
Adding base class
Olender Jul 27, 2023
6a2d1ee
adding new base class
Olender Jul 27, 2023
6362c60
debugging move
Olender Jul 27, 2023
5001d42
fixing tests and debugging
Olender Jul 27, 2023
42825f1
updating calls
Olender Jul 27, 2023
d1b0029
simplifying method
Olender Jul 27, 2023
7379589
splitting method
Olender Jul 27, 2023
cee53d4
Merge pull request #10 from Olender/reducing_code_complexity
Olender Jul 27, 2023
e554fae
moving and reducing coordinate change
Olender Jul 31, 2023
ed68415
grouping variables
Olender Jul 31, 2023
d813abe
Merge pull request #11 from Olender/reducing_code_complexity
Olender Jul 31, 2023
beec8e6
Update README.md
Olender Jul 31, 2023
00fc0de
separating method
Olender Jul 31, 2023
ef77a32
commenting out code not refactored
Olender Jul 31, 2023
f9e6094
Merge pull request #12 from Olender/reducing_code_complexity
Olender Jul 31, 2023
f29294a
reducing complexity for wave solvers
Olender Jul 31, 2023
5d9007b
Merge pull request #13 from Olender/reducing_code_complexity
Olender Jul 31, 2023
718482e
cleaning up
Olender Jul 31, 2023
63c001b
setting up coverage
Olender Jul 31, 2023
744b653
linting
Olender Jul 31, 2023
9bf81f8
Update README.md
Olender Aug 2, 2023
5755dbb
Update README.md
Olender Aug 2, 2023
7869d02
fixing inputs
Olender Aug 3, 2023
53bb78a
updating test
Olender Aug 3, 2023
7f62749
updated to read from wave obj
Olender Aug 3, 2023
ca96a43
minor edit
Olender Aug 3, 2023
68b5ff1
started adding class
Olender Aug 4, 2023
6d90b69
fixing references
Olender Aug 7, 2023
afc38ab
Merge pull request #15 from Olender/main
Olender Aug 11, 2023
28cf6be
fixing tests
Olender Aug 15, 2023
8f1435c
Merge pull request #16 from Olender/reducing_code_complexity
Olender Aug 15, 2023
18af08f
Merge branch 'main' into adding_PML
Olender Aug 15, 2023
33e8464
updating meshing functions
Olender Aug 15, 2023
8671ebe
Merge branch 'adding_PML' of github.com:Olender/spyro-1 into adding_PML
Olender Aug 15, 2023
af28be0
added for testing
Olender Aug 15, 2023
0205275
Merge branch 'adding_PML' of github.com:Olender/spyro-1 into adding_PML
Olender Aug 15, 2023
2c16df8
added debugging fucntions
Olender Aug 15, 2023
fc953f7
splitting old solver
Olender Aug 15, 2023
13ad0ed
reorganizing
Olender Aug 15, 2023
1e1a95e
seperating wave propagator for 2d
Olender Aug 15, 2023
c4a422d
making propagator independent of dimension
Olender Aug 15, 2023
0600eac
finished propagator
Olender Aug 15, 2023
139c1be
adding 3D
Olender Aug 15, 2023
d9ff590
removing unnecessary section
Olender Aug 16, 2023
62bd577
refactoring and renaming
Olender Aug 16, 2023
d7cf2c0
linting
Olender Aug 16, 2023
53a42cb
fixing tests
Olender Aug 16, 2023
19ad7fa
making pml test
Olender Aug 16, 2023
aede313
added pml test
Olender Aug 16, 2023
7387028
cleanup
Olender Aug 16, 2023
5362801
correct file location
Olender Aug 16, 2023
d89343f
fixing filename
Olender Aug 16, 2023
26e1c20
adding class selector and renaming
Olender Aug 17, 2023
b363856
adjusting imports
Olender Aug 17, 2023
bb8fbd2
linting
Olender Aug 17, 2023
50d3240
Merge pull request #18 from Olender/adding_PML
Olender Aug 17, 2023
24e9c4c
splitting firedrake mesh generation
Olender Aug 17, 2023
417f4b8
reducing complexity
Olender Aug 18, 2023
def5cfb
Merge pull request #19 from Olender/complexity_management
Olender Aug 18, 2023
208922c
Just adding documentation
Olender Aug 18, 2023
57e430f
Merge pull request #20 from Olender/complexity_management
Olender Aug 21, 2023
77058bf
reducing tests
Olender Aug 21, 2023
0e2258b
new codecov token for this fork
Olender Aug 21, 2023
7abee6d
switching to serial only
Olender Aug 21, 2023
ca25883
changing firedrake file
Olender Aug 21, 2023
7c4d78c
Merge pull request #22 from Olender/runner_debug
Olender Aug 21, 2023
41c773d
cleaning up and making sure it is abstract
Olender Aug 21, 2023
da1a89a
starting studying examples
Olender Aug 21, 2023
fe85d17
refactoring time integrator
Olender Aug 22, 2023
9e3e1ff
Started moving files
Olender Aug 23, 2023
b6513d5
Moving matrix builders
Olender Aug 25, 2023
1b6ec7f
fixing existing tests
Olender Aug 25, 2023
98a6592
joining classes
Olender Aug 25, 2023
12d3a4c
removing unused classes
Olender Aug 25, 2023
0616ea6
cleaning up imports
Olender Aug 25, 2023
4b8d0d4
finished parameters
Olender Aug 25, 2023
9d7e443
added camembert test
Olender Aug 29, 2023
f363d95
adding h parameter
Olender Aug 29, 2023
4c0da25
updating rectangle class
Olender Aug 29, 2023
bef28a3
making camembert inherit rectangle
Olender Aug 29, 2023
e7be4c7
fixed rectangle test
Olender Aug 29, 2023
0159af9
started testing plots
Olender Aug 29, 2023
8a857f5
finished plot test
Olender Aug 29, 2023
742111c
started debugging test
Olender Aug 29, 2023
6cb6433
Testing
Olender Aug 30, 2023
a13c45e
Merge branch 'adding_tests' of github.com:Olender/spyro-1 into adding…
Olender Aug 30, 2023
c8e0695
started adding utils test
Olender Aug 31, 2023
c91d1e0
added filter test
Olender Aug 31, 2023
efb88cb
added more utils test
Olender Aug 31, 2023
b4bf2f6
cleaning up
Olender Aug 31, 2023
29e8394
reducing complexity
Olender Aug 31, 2023
c362f70
Merge pull request #25 from Olender/adding_tests
Olender Aug 31, 2023
8140700
adding analytical functions
Olender Sep 4, 2023
1c80915
documentation
Olender Sep 4, 2023
04d2d9c
adding temp files for later cleanup
Olender Sep 4, 2023
a3c2995
finished changes required for analytical 2d solve and test
Olender Sep 4, 2023
9166740
just cleaning up
Olender Sep 5, 2023
e5f1b64
fixing 3d quad
Olender Sep 5, 2023
bd1f77b
adding temp 3d test
Olender Sep 5, 2023
f8d0db2
adding 3D hexa test
Olender Sep 5, 2023
e8904c2
updating core count
Olender Sep 5, 2023
12c85ff
adding coverage for 3d
Olender Sep 5, 2023
25801f0
testing 3d and then covering
Olender Sep 5, 2023
0f6aaf9
Merge pull request #26 from Olender/testing_3d
Olender Sep 5, 2023
da6973f
Update README.md
Olender Sep 6, 2023
8d084ba
removing temp file
Olender Sep 6, 2023
0062572
Merge pull request #27 from Olender/Olender-patch-1
Olender Sep 6, 2023
c228c9c
started making temp files
Olender Sep 6, 2023
2f7f5a2
started adding cpw calc
Olender Sep 7, 2023
952eeb1
starting first test
Olender Sep 7, 2023
a3584eb
added first test
Olender Sep 7, 2023
2fb3a2a
added reference solution
Olender Sep 7, 2023
a2ac3f6
added save and load option
Olender Sep 8, 2023
be7ca53
moslty linting
Olender Sep 10, 2023
8bb4c56
started adding seismicmesh
Olender Sep 10, 2023
b7ded07
linting tests
Olender Sep 10, 2023
377d5d5
added homogeneous seismicmesh calculation
Olender Sep 12, 2023
3611456
finished first test
Olender Sep 12, 2023
0fb8386
setting up radius calc
Olender Sep 12, 2023
c9c64c5
finished homogeneous test
Olender Sep 12, 2023
8ccb627
cleanup
Olender Sep 12, 2023
e703130
getting ready to save solution
Olender Sep 12, 2023
a0dd7ca
it started running
Olender Sep 17, 2023
7c4d8f1
trying first case
Olender Sep 17, 2023
6dfd26b
testing
Olender Sep 18, 2023
6d4c227
adding new error calc
Olender Sep 18, 2023
8ca5810
got it running
Olender Sep 18, 2023
8bf2fbb
updating results
Olender Sep 18, 2023
3cf60b4
added results and figure calculation
Olender Sep 18, 2023
2d03b04
linting
Olender Sep 18, 2023
836e552
debugged wavelet generation
Olender Sep 19, 2023
d868fa8
finishing simulation
Olender Sep 19, 2023
d0b0ee0
updating and cleaning up
Olender Sep 29, 2023
441594a
updating test
Olender Sep 29, 2023
aa53fe7
putting reference solution file in correctly
Olender Sep 29, 2023
6c87100
cleanup
Olender Sep 29, 2023
5461c47
Merge pull request #30 from Olender/cells_per_wavelength
Olender Sep 29, 2023
fb438d9
cleaning up repeated sections
Olender Oct 2, 2023
0e1ffa6
splitting methods
Olender Oct 2, 2023
f5169ba
expanding tests
Olender Oct 2, 2023
c5694ee
just linting
Olender Oct 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .coverage
Binary file not shown.
61 changes: 32 additions & 29 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,40 +15,43 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Running serial tests in parallel (only one test per core)
- name: Running serial tests
run: |
source /home/olender/Firedrakes/main/firedrake/bin/activate
pytest -n 10 --cov-report=xml --cov=spyro test/
- name: Running serial tests for adjoint
run: |
source /home/olender/Firedrakes/main/firedrake/bin/activate
pytest -n 10 --cov-report=xml --cov-append --cov=spyro test_ad/
- name: Running parallel tests
run: |
source /home/olender/Firedrakes/main/firedrake/bin/activate
cp /home/olender/Testing_files/velocity_models/* velocity_models/
cp /home/olender/Testing_files/meshes/* meshes/
mpiexec -n 10 pytest test_parallel/test_forward.py
- name: Covering parallel tests
continue-on-error: true
run: |
source /home/olender/Firedrakes/main/firedrake/bin/activate
cp /home/olender/Testing_files/velocity_models/* velocity_models/
cp /home/olender/Testing_files/meshes/* meshes/
mpiexec -n 10 pytest --cov-report=xml --cov-append --cov=spyro test_parallel/test_forward.py
source /home/olender/Firedrakes/newest3/firedrake/bin/activate
pytest --cov-report=xml --cov=spyro test/
- name: Running parallel 3D forward test
run: |
source /home/olender/Firedrakes/main/firedrake/bin/activate
cp /home/olender/Testing_files/velocity_models/* velocity_models/
cp /home/olender/Testing_files/meshes/* meshes/
mpiexec -n 10 pytest test_3d/test_forward_3d.py
source /home/olender/Firedrakes/newest3/firedrake/bin/activate
mpiexec -n 6 pytest test_3d/test_hexahedral_convergence.py
- name: Covering parallel 3D forward test
continue-on-error: true
run: |
source /home/olender/Firedrakes/main/firedrake/bin/activate
cp /home/olender/Testing_files/velocity_models/* velocity_models/
cp /home/olender/Testing_files/meshes/* meshes/
mpiexec -n 10 pytest --cov-report=xml --cov-append --cov=spyro test_3d/test_forward_3d.py
source /home/olender/Firedrakes/newest3/firedrake/bin/activate
mpiexec -n 6 pytest --cov-report=xml --cov-append --cov=spyro test_3d/test_hexahedral_convergence.py
# - name: Running serial tests for adjoint
# run: |
# source /home/olender/Firedrakes/main/firedrake/bin/activate
# pytest -n 10 --cov-report=xml --cov-append --cov=spyro test_ad/
# - name: Running parallel tests
# run: |
# source /home/olender/Firedrakes/main/firedrake/bin/activate
# cp /home/olender/Testing_files/velocity_models/* velocity_models/
# cp /home/olender/Testing_files/meshes/* meshes/
# mpiexec -n 10 pytest test_parallel/test_forward.py
# - name: Covering parallel tests
# continue-on-error: true
# run: |
# source /home/olender/Firedrakes/main/firedrake/bin/activate
# cp /home/olender/Testing_files/velocity_models/* velocity_models/
# cp /home/olender/Testing_files/meshes/* meshes/
# mpiexec -n 10 pytest --cov-report=xml --cov-append --cov=spyro test_parallel/test_forward.py
# - name: Covering parallel 3D forward test
# continue-on-error: true
# run: |
# source /home/olender/Firedrakes/main/firedrake/bin/activate
# cp /home/olender/Testing_files/velocity_models/* velocity_models/
# cp /home/olender/Testing_files/meshes/* meshes/
# mpiexec -n 10 pytest --cov-report=xml --cov-append --cov=spyro test_3d/test_forward_3d.py
- name: Uploading coverage to Codecov
run: export CODECOV_TOKEN="6cd21147-54f7-4b77-94ad-4b138053401d" && bash <(curl -s https://codecov.io/bash)
run: export CODECOV_TOKEN="057ec853-d7ea-4277-819b-0c5ea2f9ff57" && bash <(curl -s https://codecov.io/bash)

183 changes: 84 additions & 99 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
[![DOI](https://zenodo.org/badge/318542339.svg)](https://zenodo.org/badge/latestdoi/318542339)
[![Python tests](https://github.com/NDF-Poli-USP/spyro/actions/workflows/python-tests.yml/badge.svg)](https://github.com/NDF-Poli-USP/spyro/actions/workflows/python-tests.yml)
[![codecov](https://codecov.io/gh/NDF-Poli-USP/spyro/branch/main/graph/badge.svg?token=8NM4N4N7YW)](https://codecov.io/gh/NDF-Poli-USP/spyro)
[![codecov](https://codecov.io/gh/Olender/spyro-1/graph/badge.svg?token=69M30UMRFD)](https://codecov.io/gh/Olender/spyro-1)
[![CodeScene Code Health](https://codescene.io/projects/42047/status-badges/code-health)](https://codescene.io/projects/42047)

spyro: Acoustic wave modeling in Firedrake
SPIRO: Seismic Parallel Inversion and Reconstruction Optimization framework
============================================

spyro is a Python library for modeling acoustic waves. The main
Acoustic wave modeling in Firedrake

SPIRO is a Python library for modeling acoustic waves. The main
functionality is a set of forward and adjoint wave propagators for solving the acoustic wave equation in the time domain.
These wave propagators can be used to form complete full waveform inversion (FWI) applications. See the [demos](https://github.com/krober10nd/spyro/tree/main/demos).
To implement these solvers, spyro uses the finite element package [Firedrake](https://www.firedrakeproject.org/index.html).
To implement these solvers, SPIRO uses the finite element package [Firedrake](https://www.firedrakeproject.org/index.html).

To use Spyro, you'll need to have some knowledge of Python and some basic concepts in inverse modeling relevant to active-sourcce seismology.
To use SPIRO, you'll need to have some knowledge of Python and some basic concepts in inverse modeling relevant to active-sourcce seismology.

Discussions about development take place on our Slack channel. Everyone is invited to join using the link: https://join.slack.com/t/spyroworkspace/shared_invite/zt-u87ih28m-2h9JobfkdArs4ku3a1wLLQ

Expand Down Expand Up @@ -51,137 +54,119 @@ See the demos folder for an FWI example (this requires some other dependencies p
![Above shows the simulation at two timesteps in ParaView that results from running the code below](https://user-images.githubusercontent.com/18619644/94087976-7e81df00-fde5-11ea-96c0-474348286091.png)

```python
from firedrake import (
RectangleMesh,
FunctionSpace,
Function,
SpatialCoordinate,
conditional,
File,
)

import spyro

model = {}

# Choose method and parameters
model["opts"] = {
"method": "KMV", # either CG or KMV
"quadratrue": "KMV", # Equi or KMV
"degree": 1, # p order
"dimension": 2, # dimension
dictionary = {}

# Choose spatial discretization method and parameters
dictionary["options"] = {
# simplexes such as triangles or tetrahedra (T) or quadrilaterals (Q)
"cell_type": "T",
# lumped, equispaced or DG, default is lumped "method":"MLT",
# (MLT/spectral_quadrilateral/DG_triangle/DG_quadrilateral)
# You can either specify a cell_type+variant or a method.
"variant": 'lumped',
# Polynomial order of the spatial discretion's basis functions.
# For MLT we recomend 4th order in 2D, 3rd order in 3D, for SEM 4th or 8th.
"degree": 4,
# Dimension (2 or 3)
"dimension": 2,
}

# Number of cores for the shot. For simplicity, we keep things serial.
# spyro however supports both spatial parallelism and "shot" parallelism.
model["parallelism"] = {
"type": "spatial", # options: automatic (same number of cores for evey processor) or spatial
# Number of cores for the shot. For simplicity, we keep things automatic.
# SPIRO supports both spatial parallelism and "shot" parallelism.
dictionary["parallelism"] = {
# options: automatic (same number of cores for every shot) or spatial
"type": "automatic",
}

# Define the domain size without the PML. Here we'll assume a 0.75 x 1.50 km
# domain and reserve the remaining 250 m for the Perfectly Matched Layer (PML) to absorb
# outgoing waves on three sides (eg., -z, +-x sides) of the domain.
model["mesh"] = {
"Lz": 0.75, # depth in km - always positive
"Lx": 1.5, # width in km - always positive
"Ly": 0.0, # thickness in km - always positive
"meshfile": "not_used.msh",
"initmodel": "not_used.hdf5",
"truemodel": "not_used.hdf5",
}

# Specify a 250-m PML on the three sides of the domain to damp outgoing waves.
model["BCs"] = {
"status": True, # True or false
"outer_bc": "non-reflective", # None or non-reflective (outer boundary condition)
"damping_type": "polynomial", # polynomial, hyperbolic, shifted_hyperbolic
"exponent": 2, # damping layer has a exponent variation
"cmax": 4.7, # maximum acoustic wave velocity in PML - km/s
"R": 1e-6, # theoretical reflection coefficient
"lz": 0.25, # thickness of the PML in the z-direction (km) - always positive
"lx": 0.25, # thickness of the PML in the x-direction (km) - always positive
"ly": 0.0, # thickness of the PML in the y-direction (km) - always positive
dictionary["mesh"] = {
# depth in km - always positive
"Lz": 0.75,
# width in km - always positive
"Lx": 1.50,
# thickness in km - always positive
"Ly": 0.0,
# If we are loading and external .msh mesh file
"mesh_file": None,
# options: None (default), firedrake_mesh, user_mesh, or SeismicMesh
# use this opion if your are not loading an external file
# 'firedrake_mesh' will create an automatic mesh using firedrake's built-in meshing tools
# 'user_mesh' gives the option to load other user generated meshes from unsuported formats
# 'SeismicMesh' automatically creates a waveform adapted unstructured mesh to reduce total
# DoFs using the SeismicMesh tool.
"mesh_type": "firedrake_mesh",
}

# Create a source injection operator. Here we use a single source with a
# Ricker wavelet that has a peak frequency of 8 Hz injected at the center of the mesh.
# We also specify to record the solution at 101 microphones near the top of the domain.
# This transect of receivers is created with the helper function `create_transect`.
model["acquisition"] = {
"source_type": "Ricker",
"source_pos": [(-0.1, 0.75)],
dictionary["acquisition"] = {
"source_type": "ricker",
"source_locations": [(-0.3, 0.75)],
"frequency": 8.0,
"delay": 1.0,
"receiver_locations": spyro.create_transect(
(-0.10, 0.1), (-0.10, 1.4), 100
(-0.5, 0.1), (-0.5, 1.4), 100
),
}

# Simulate for 2.0 seconds.
model["timeaxis"] = {
"t0": 0.0, # Initial time for event
"tf": 2.00, # Final time for event
"dt": 0.0005, # timestep size
"amplitude": 1, # the Ricker has an amplitude of 1.
"nspool": 100, # how frequently to output solution to pvds
"fspool": 100, # how frequently to save solution to RAM
dictionary["time_axis"] = {
# Initial time for event
"initial_time": 0.0,
# Final time for event
"final_time": 0.50,
# timestep size
"dt": 0.0001,
# the Ricker has an amplitude of 1.
"amplitude": 1,
# how frequently to output solution to pvds
"output_frequency": 100,
# how frequently to save solution to RAM
"gradient_sampling_frequency": 100,
}

dictionary["visualization"] = {
"forward_output" : True,
"output_filename": "results/forward_output.pvd",
"fwi_velocity_model_output": False,
"velocity_model_filename": None,
"gradient_output": False,
"gradient_filename": None,
}

# Create a simple mesh of a rectangle ∈ [1 x 2] km with ~100 m sized elements
# and then create a function space for P=1 Continuous Galerkin FEM
mesh = RectangleMesh(100, 200, 1.0, 2.0)

# We edit the coordinates of the mesh so that it's in the (z, x) plane
# and has a domain padding of 250 m on three sides, which will be used later to show
# the Perfectly Matched Layer (PML). More complex 2D/3D meshes can be automatically generated with
# SeismicMesh https://github.com/krober10nd/SeismicMesh
mesh.coordinates.dat.data[:, 0] -= 1.0
mesh.coordinates.dat.data[:, 1] -= 0.25

# Create an AcousticWave object with the above dictionary.
Wave_obj = spyro.AcousticWave(dictionary=dictionary)

# Create the computational environment
comm = spyro.utils.mpi_init(model)
# Defines the element size in the automatically generated firedrake mesh.
Wave_obj.set_mesh(dx=0.01)

element = spyro.domains.space.FE_method(
mesh, model["opts"]["method"], model["opts"]["degree"]
)
V = FunctionSpace(mesh, element)

# Manually create a simple two layer seismic velocity model `vp`.
# Note: the user can specify their own velocity model in a HDF5 file format
# in the above two lines using SeismicMesh.
# If so, the HDF5 file has to contain an array with
# Manually create a simple two layer seismic velocity model.
# Note: the user can specify their own velocity model in a HDF5 or SEG-Y file format.
# The HDF5 file has to contain an array with
# the velocity data and it is linearly interpolated onto the mesh nodes at run-time.
x, y = SpatialCoordinate(mesh)
velocity = conditional(x > -0.35, 1.5, 3.0)
vp = Function(V, name="velocity").interpolate(velocity)
# These pvd files can be easily visualized in ParaView!
File("simple_velocity_model.pvd").write(vp)


# Now we instantiate both the receivers and source objects.
sources = spyro.Sources(model, mesh, V, comm)

receivers = spyro.Receivers(model, mesh, V, comm)

# Create a wavelet to force the simulation
wavelet = spyro.full_ricker_wavelet(dt=0.0005, tf=2.0, freq=8.0)
z = Wave_obj.mesh_z
import firedrake as fire
velocity_conditional = fire.conditional(z > -0.35, 1.5, 3.0)
Wave_obj.set_initial_velocity_model(conditional=velocity_conditional, output=True)

# And now we simulate the shot using a 2nd order central time-stepping scheme
# Note: simulation results are stored in the folder `~/results/` by default
p_field, p_at_recv = spyro.solvers.forward(
model, mesh, comm, vp, sources, wavelet, receivers
)
Wave_obj.forward_solve()

# Visualize the shot record
spyro.plots.plot_shots(model, comm, p_at_recv)
spyro.plots.plot_shots(Wave_obj, show=True)

# Save the shot (a Numpy array) as a pickle for other use.
spyro.io.save_shots(model, comm, p_at_recv)
spyro.io.save_shots(Wave_obj)

# can be loaded back via
my_shot = spyro.io.load_shots(model, comm)
my_shot = spyro.io.load_shots(Wave_obj)
```

### Testing
Expand Down
37 changes: 37 additions & 0 deletions results/receivers.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Z, X
-3.75, 3.75
-3.45, 3.75
-3.15, 3.75
-2.85, 3.75
-2.55, 3.75
-2.25, 3.75
-3.75, 4.05
-3.45, 4.05
-3.15, 4.05
-2.85, 4.05
-2.55, 4.05
-2.25, 4.05
-3.75, 4.35
-3.45, 4.35
-3.15, 4.35
-2.85, 4.35
-2.55, 4.35
-2.25, 4.35
-3.75, 4.65
-3.45, 4.65
-3.15, 4.65
-2.85, 4.65
-2.55, 4.65
-2.25, 4.65
-3.75, 4.95
-3.45, 4.95
-3.15, 4.95
-2.85, 4.95
-2.55, 4.95
-2.25, 4.95
-3.75, 5.25
-3.45, 5.25
-3.15, 5.25
-2.85, 5.25
-2.55, 5.25
-2.25, 5.25
2 changes: 2 additions & 0 deletions results/sources.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Z, X
-6.0, 4.5
7 changes: 7 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[flake8]
ignore =
E501,F403,F405,E226,E402,E721,E731,E741,W503,F999,
N801,N802,N803,N806,N807,N811,N813,N814,N815,N816
exclude = .git,__pycache__
[coverage:run]
omit=*/site-packages/*,*/test/*,*/.eggs/*,/home/alexandre/firedrake/*
2 changes: 1 addition & 1 deletion shots/README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Storage folder for pickled shots. Make sure to keep it clean after several runs!
* This directory contains the shot records
Loading
Loading