mirror of
https://github.com/wassname/simpeg.git
synced 2026-06-28 07:34:52 +08:00
Merge branch 'FDEMrefactor'
This commit is contained in:
+246
@@ -42,3 +42,249 @@ nosetests.xml
|
||||
*.sublime-workspace
|
||||
docs/_build/
|
||||
*.ipynb_checkpoints
|
||||
notebooks/scipy2015/001-Inversion_NoStopping.npy
|
||||
notebooks/scipy2015/001-Inversion_NoStoppingregMesh_smoothFalse.npy
|
||||
notebooks/scipy2015/002-Inversion_NoStoppingregMesh_smoothFalse.npy
|
||||
notebooks/scipy2015/003-Inversion_NoStoppingregMesh_smoothFalse.npy
|
||||
notebooks/scipy2015/004-Inversion_NoStoppingregMesh_smoothFalse.npy
|
||||
notebooks/scipy2015/005-Inversion_NoStoppingregMesh_smoothFalse.npy
|
||||
notebooks/scipy2015/006-Inversion_NoStoppingregMesh_smoothFalse.npy
|
||||
notebooks/scipy2015/007-Inversion_NoStoppingregMesh_smoothFalse.npy
|
||||
notebooks/scipy2015/008-Inversion_NoStoppingregMesh_smoothFalse.npy
|
||||
notebooks/scipy2015/009-Inversion_NoStoppingregMesh_smoothFalse.npy
|
||||
notebooks/scipy2015/010-Inversion_NoStoppingregMesh_smoothFalse.npy
|
||||
notebooks/scipy2015/011-Inversion_NoStoppingregMesh_smoothFalse.npy
|
||||
notebooks/scipy2015/012-Inversion_NoStoppingregMesh_smoothFalse.npy
|
||||
notebooks/scipy2015/013-Inversion_NoStoppingregMesh_smoothFalse.npy
|
||||
notebooks/scipy2015/014-Inversion_NoStoppingregMesh_smoothFalse.npy
|
||||
notebooks/scipy2015/015-Inversion_NoStoppingregMesh_smoothFalse.npy
|
||||
notebooks/scipy2015/016-Inversion_NoStoppingregMesh_smoothFalse.npy
|
||||
notebooks/scipy2015/017-Inversion_NoStoppingregMesh_smoothFalse.npy
|
||||
notebooks/scipy2015/018-Inversion_NoStoppingregMesh_smoothFalse.npy
|
||||
notebooks/scipy2015/019-Inversion_NoStoppingregMesh_smoothFalse.npy
|
||||
notebooks/scipy2015/020-Inversion_NoStoppingregMesh_smoothFalse.npy
|
||||
notebooks/scipy2015/021-Inversion_NoStoppingregMesh_smoothFalse.npy
|
||||
notebooks/scipy2015/022-Inversion_NoStoppingregMesh_smoothFalse.npy
|
||||
notebooks/scipy2015/023-Inversion_NoStoppingregMesh_smoothFalse.npy
|
||||
notebooks/scipy2015/024-Inversion_NoStoppingregMesh_smoothFalse.npy
|
||||
notebooks/scipy2015/025-Inversion_NoStoppingregMesh_smoothFalse.npy
|
||||
notebooks/scipy2015/026-Inversion_NoStoppingregMesh_smoothFalse.npy
|
||||
notebooks/scipy2015/027-Inversion_NoStoppingregMesh_smoothFalse.npy
|
||||
notebooks/scipy2015/028-Inversion_NoStoppingregMesh_smoothFalse.npy
|
||||
notebooks/scipy2015/029-Inversion_NoStoppingregMesh_smoothFalse.npy
|
||||
notebooks/scipy2015/030-Inversion_NoStoppingregMesh_smoothFalse.npy
|
||||
notebooks/001-InversionModel-2015-11-05-10-20.npy
|
||||
notebooks/001-InversionModel-2015-11-05-13-19.npy
|
||||
notebooks/001-InversionModel-2015-11-05-14-57.npy
|
||||
notebooks/001-InversionModel-2015-11-10-16-51.npy
|
||||
notebooks/001-InversionModel-2015-11-10-19-15.npy
|
||||
notebooks/001-InversionModel-2015-11-13-10-29.npy
|
||||
notebooks/002-InversionModel-2015-11-05-10-20.npy
|
||||
notebooks/002-InversionModel-2015-11-05-13-19.npy
|
||||
notebooks/002-InversionModel-2015-11-05-14-57.npy
|
||||
notebooks/002-InversionModel-2015-11-10-16-51.npy
|
||||
notebooks/002-InversionModel-2015-11-10-19-15.npy
|
||||
notebooks/002-InversionModel-2015-11-13-10-29.npy
|
||||
notebooks/003-InversionModel-2015-11-05-10-20.npy
|
||||
notebooks/0??-InversionModel-2015-11-05-13-19.npy
|
||||
notebooks/006-InversionModel-2015-11-05-14-57.npy
|
||||
notebooks/003-InversionModel-2015-11-05-14-57.npy
|
||||
notebooks/003-InversionModel-2015-11-10-16-51.npy
|
||||
notebooks/003-InversionModel-2015-11-10-19-15.npy
|
||||
notebooks/003-InversionModel-2015-11-13-10-29.npy
|
||||
notebooks/004-InversionModel-2015-11-05-10-20.npy
|
||||
notebooks/004-InversionModel-2015-11-05-14-57.npy
|
||||
notebooks/004-InversionModel-2015-11-10-16-51.npy
|
||||
notebooks/004-InversionModel-2015-11-10-19-15.npy
|
||||
notebooks/004-InversionModel-2015-11-13-10-29.npy
|
||||
notebooks/005-InversionModel-2015-11-05-10-20.npy
|
||||
notebooks/005-InversionModel-2015-11-05-14-57.npy
|
||||
notebooks/005-InversionModel-2015-11-10-16-51.npy
|
||||
notebooks/005-InversionModel-2015-11-10-19-15.npy
|
||||
notebooks/005-InversionModel-2015-11-13-10-29.npy
|
||||
notebooks/006-InversionModel-2015-11-05-10-20.npy
|
||||
notebooks/006-InversionModel-2015-11-10-16-51.npy
|
||||
notebooks/006-InversionModel-2015-11-10-19-15.npy
|
||||
notebooks/006-InversionModel-2015-11-13-10-29.npy
|
||||
notebooks/007-InversionModel-2015-11-05-10-20.npy
|
||||
notebooks/007-InversionModel-2015-11-05-14-57.npy
|
||||
notebooks/007-InversionModel-2015-11-10-16-51.npy
|
||||
notebooks/007-InversionModel-2015-11-10-19-15.npy
|
||||
notebooks/007-InversionModel-2015-11-13-10-29.npy
|
||||
notebooks/008-InversionModel-2015-11-05-10-20.npy
|
||||
notebooks/008-InversionModel-2015-11-05-14-57.npy
|
||||
notebooks/008-InversionModel-2015-11-10-16-51.npy
|
||||
notebooks/008-InversionModel-2015-11-10-19-15.npy
|
||||
notebooks/008-InversionModel-2015-11-13-10-29.npy
|
||||
notebooks/009-InversionModel-2015-11-05-10-20.npy
|
||||
notebooks/009-InversionModel-2015-11-05-14-57.npy
|
||||
notebooks/009-InversionModel-2015-11-10-16-51.npy
|
||||
notebooks/009-InversionModel-2015-11-10-19-15.npy
|
||||
notebooks/009-InversionModel-2015-11-13-10-29.npy
|
||||
notebooks/010-InversionModel-2015-11-05-10-20.npy
|
||||
notebooks/010-InversionModel-2015-11-05-14-57.npy
|
||||
notebooks/010-InversionModel-2015-11-10-16-51.npy
|
||||
notebooks/010-InversionModel-2015-11-10-19-15.npy
|
||||
notebooks/010-InversionModel-2015-11-13-10-29.npy
|
||||
notebooks/011-InversionModel-2015-11-05-14-57.npy
|
||||
notebooks/011-InversionModel-2015-11-10-16-51.npy
|
||||
notebooks/011-InversionModel-2015-11-10-19-15.npy
|
||||
notebooks/011-InversionModel-2015-11-13-10-29.npy
|
||||
notebooks/012-InversionModel-2015-11-05-14-57.npy
|
||||
notebooks/012-InversionModel-2015-11-10-16-51.npy
|
||||
notebooks/012-InversionModel-2015-11-10-19-15.npy
|
||||
notebooks/012-InversionModel-2015-11-13-10-29.npy
|
||||
notebooks/013-InversionModel-2015-11-05-14-57.npy
|
||||
notebooks/013-InversionModel-2015-11-10-16-51.npy
|
||||
notebooks/013-InversionModel-2015-11-10-19-15.npy
|
||||
notebooks/013-InversionModel-2015-11-13-10-29.npy
|
||||
notebooks/014-InversionModel-2015-11-05-14-57.npy
|
||||
notebooks/014-InversionModel-2015-11-10-16-51.npy
|
||||
notebooks/014-InversionModel-2015-11-10-19-15.npy
|
||||
notebooks/014-InversionModel-2015-11-13-10-29.npy
|
||||
notebooks/015-InversionModel-2015-11-05-14-57.npy
|
||||
notebooks/015-InversionModel-2015-11-10-16-51.npy
|
||||
notebooks/015-InversionModel-2015-11-10-19-15.npy
|
||||
notebooks/015-InversionModel-2015-11-13-10-29.npy
|
||||
notebooks/016-InversionModel-2015-11-05-14-57.npy
|
||||
notebooks/016-InversionModel-2015-11-10-16-51.npy
|
||||
notebooks/016-InversionModel-2015-11-10-19-15.npy
|
||||
notebooks/016-InversionModel-2015-11-13-10-29.npy
|
||||
notebooks/017-InversionModel-2015-11-05-14-57.npy
|
||||
notebooks/017-InversionModel-2015-11-10-16-51.npy
|
||||
notebooks/017-InversionModel-2015-11-10-19-15.npy
|
||||
notebooks/017-InversionModel-2015-11-13-10-29.npy
|
||||
notebooks/018-InversionModel-2015-11-05-14-57.npy
|
||||
notebooks/018-InversionModel-2015-11-10-16-51.npy
|
||||
notebooks/018-InversionModel-2015-11-10-19-15.npy
|
||||
notebooks/019-InversionModel-2015-11-05-14-57.npy
|
||||
notebooks/019-InversionModel-2015-11-10-16-51.npy
|
||||
notebooks/019-InversionModel-2015-11-10-19-15.npy
|
||||
notebooks/020-InversionModel-2015-11-05-14-57.npy
|
||||
notebooks/020-InversionModel-2015-11-10-16-51.npy
|
||||
notebooks/020-InversionModel-2015-11-10-19-15.npy
|
||||
notebooks/021-InversionModel-2015-11-05-14-57.npy
|
||||
notebooks/021-InversionModel-2015-11-10-16-51.npy
|
||||
notebooks/021-InversionModel-2015-11-10-19-15.npy
|
||||
notebooks/022-InversionModel-2015-11-05-14-57.npy
|
||||
notebooks/022-InversionModel-2015-11-10-16-51.npy
|
||||
notebooks/022-InversionModel-2015-11-10-19-15.npy
|
||||
notebooks/023-InversionModel-2015-11-05-14-57.npy
|
||||
notebooks/023-InversionModel-2015-11-10-16-51.npy
|
||||
notebooks/023-InversionModel-2015-11-10-19-15.npy
|
||||
notebooks/024-InversionModel-2015-11-05-14-57.npy
|
||||
notebooks/024-InversionModel-2015-11-10-16-51.npy
|
||||
notebooks/024-InversionModel-2015-11-10-19-15.npy
|
||||
notebooks/025-InversionModel-2015-11-05-14-57.npy
|
||||
notebooks/025-InversionModel-2015-11-10-16-51.npy
|
||||
notebooks/025-InversionModel-2015-11-10-19-15.npy
|
||||
notebooks/026-InversionModel-2015-11-05-14-57.npy
|
||||
notebooks/026-InversionModel-2015-11-10-16-51.npy
|
||||
notebooks/026-InversionModel-2015-11-10-19-15.npy
|
||||
notebooks/027-InversionModel-2015-11-05-14-57.npy
|
||||
notebooks/027-InversionModel-2015-11-10-16-51.npy
|
||||
notebooks/027-InversionModel-2015-11-10-19-15.npy
|
||||
notebooks/028-InversionModel-2015-11-05-14-57.npy
|
||||
notebooks/028-InversionModel-2015-11-10-16-51.npy
|
||||
notebooks/028-InversionModel-2015-11-10-19-15.npy
|
||||
notebooks/029-InversionModel-2015-11-05-14-57.npy
|
||||
notebooks/029-InversionModel-2015-11-10-16-51.npy
|
||||
notebooks/029-InversionModel-2015-11-10-19-15.npy
|
||||
notebooks/030-InversionModel-2015-11-05-14-57.npy
|
||||
notebooks/030-InversionModel-2015-11-10-16-51.npy
|
||||
notebooks/030-InversionModel-2015-11-10-19-15.npy
|
||||
notebooks/InversionModel-2015-11-05-10-20_001.vtr
|
||||
notebooks/InversionModel-2015-11-05-10-20_002.vtr
|
||||
notebooks/InversionModel-2015-11-05-10-20_003.vtr
|
||||
notebooks/InversionModel-2015-11-05-10-20_004.vtr
|
||||
notebooks/InversionModel-2015-11-05-10-20_005.vtr
|
||||
notebooks/InversionModel-2015-11-05-10-20_006.vtr
|
||||
notebooks/InversionModel-2015-11-05-10-20_007.vtr
|
||||
notebooks/InversionModel-2015-11-05-10-20_008.vtr
|
||||
notebooks/InversionModel-2015-11-05-10-20_009.vtr
|
||||
notebooks/InversionModel-2015-11-05-10-20_010.vtr
|
||||
notebooks/InversionModel-2015-11-05-13-19_001.vtr
|
||||
notebooks/InversionModel-2015-11-05-13-19_002.vtr
|
||||
notebooks/InversionModel-2015-11-05-13-19_003.vtr
|
||||
notebooks/InversionModel-2015-11-05-13-19_004.vtr
|
||||
notebooks/InversionModel-2015-11-05-13-19_005.vtr
|
||||
notebooks/InversionModel-2015-11-05-13-19_006.vtr
|
||||
notebooks/InversionModel-2015-11-05-13-19_007.vtr
|
||||
notebooks/InversionModel-2015-11-05-13-19_008.vtr
|
||||
notebooks/InversionModel-2015-11-05-13-19_009.vtr
|
||||
notebooks/InversionModel-2015-11-05-13-19_010.vtr
|
||||
notebooks/InversionModel-2015-11-05-13-19_011.vtr
|
||||
notebooks/InversionModel-2015-11-05-13-19_012.vtr
|
||||
notebooks/InversionModel-2015-11-05-14-57_001.vtr
|
||||
notebooks/InversionModel-2015-11-05-14-57_002.vtr
|
||||
notebooks/InversionModel-2015-11-05-14-57_003.vtr
|
||||
notebooks/InversionModel-2015-11-05-14-57_004.vtr
|
||||
notebooks/InversionModel-2015-11-05-14-57_005.vtr
|
||||
notebooks/InversionModel-2015-11-05-14-57_006.vtr
|
||||
notebooks/InversionModel-2015-11-05-14-57_007.vtr
|
||||
notebooks/InversionModel-2015-11-05-14-57_008.vtr
|
||||
notebooks/InversionModel-2015-11-05-14-57_009.vtr
|
||||
notebooks/InversionModel-2015-11-05-14-57_010.vtr
|
||||
notebooks/InversionModel-2015-11-05-14-57_011.vtr
|
||||
notebooks/InversionModel-2015-11-05-14-57_012.vtr
|
||||
notebooks/InversionModel-2015-11-05-14-57_013.vtr
|
||||
notebooks/InversionModel-2015-11-05-14-57_014.vtr
|
||||
notebooks/InversionModel-2015-11-05-14-57_015.vtr
|
||||
notebooks/InversionModel-2015-11-05-14-57_016.vtr
|
||||
notebooks/InversionModel-2015-11-05-14-57_017.vtr
|
||||
notebooks/InversionModel-2015-11-05-14-57_018.vtr
|
||||
notebooks/InversionModel-2015-11-05-14-57_019.vtr
|
||||
notebooks/InversionModel-2015-11-05-14-57_020.vtr
|
||||
notebooks/InversionModel-2015-11-05-14-57_021.vtr
|
||||
notebooks/InversionModel-2015-11-05-14-57_022.vtr
|
||||
notebooks/InversionModel-2015-11-05-14-57_023.vtr
|
||||
notebooks/InversionModel-2015-11-05-14-57_024.vtr
|
||||
notebooks/InversionModel-2015-11-05-14-57_025.vtr
|
||||
notebooks/InversionModel-2015-11-05-14-57_026.vtr
|
||||
notebooks/InversionModel-2015-11-05-14-57_027.vtr
|
||||
notebooks/InversionModel-2015-11-05-14-57_028.vtr
|
||||
notebooks/InversionModel-2015-11-05-14-57_029.vtr
|
||||
notebooks/InversionModel-2015-11-05-14-57_030.vtr
|
||||
notebooks/InversionModel-2015-11-10-16-51_001.vtr
|
||||
notebooks/InversionModel-2015-11-10-16-51_002.vtr
|
||||
notebooks/InversionModel-2015-11-10-16-51_003.vtr
|
||||
notebooks/InversionModel-2015-11-10-16-51_004.vtr
|
||||
notebooks/InversionModel-2015-11-10-16-51_005.vtr
|
||||
notebooks/InversionModel-2015-11-10-16-51_006.vtr
|
||||
notebooks/InversionModel-2015-11-10-16-51_007.vtr
|
||||
notebooks/InversionModel-2015-11-10-16-51_008.vtr
|
||||
notebooks/InversionModel-2015-11-10-16-51_009.vtr
|
||||
notebooks/InversionModel-2015-11-10-16-51_010.vtr
|
||||
notebooks/InversionModel-2015-11-10-16-51_011.vtr
|
||||
notebooks/InversionModel-2015-11-10-16-51_012.vtr
|
||||
notebooks/InversionModel-2015-11-10-16-51_013.vtr
|
||||
notebooks/InversionModel-2015-11-10-16-51_014.vtr
|
||||
notebooks/InversionModel-2015-11-10-16-51_015.vtr
|
||||
notebooks/InversionModel-2015-11-10-16-51_016.vtr
|
||||
notebooks/InversionModel-2015-11-10-16-51_017.vtr
|
||||
notebooks/InversionModel-2015-11-10-16-51_018.vtr
|
||||
notebooks/InversionModel-2015-11-10-16-51_019.vtr
|
||||
notebooks/InversionModel-2015-11-10-16-51_020.vtr
|
||||
notebooks/InversionModel-2015-11-10-16-51_021.vtr
|
||||
notebooks/InversionModel-2015-11-10-16-51_022.vtr
|
||||
notebooks/InversionModel-2015-11-10-16-51_023.vtr
|
||||
notebooks/InversionModel-2015-11-10-16-51_024.vtr
|
||||
notebooks/InversionModel-2015-11-10-16-51_025.vtr
|
||||
notebooks/InversionModel-2015-11-10-16-51_026.vtr
|
||||
notebooks/InversionModel-2015-11-10-16-51_027.vtr
|
||||
notebooks/InversionModel-2015-11-10-16-51_028.vtr
|
||||
notebooks/InversionModel-2015-11-10-16-51_029.vtr
|
||||
notebooks/InversionModel-2015-11-10-16-51_030.vtr
|
||||
notebooks/MT Script-3D_InversionTest.ipynb
|
||||
notebooks/MT3D_dobs.npy
|
||||
notebooks/MT3D_dtrue.npy
|
||||
notebooks/trueModel.vtr
|
||||
notebooks/018-InversionModel-2015-11-13-10-29.npy
|
||||
notebooks/scipy2015/SeogiModelMT3Dfor21Dinv/xyzmod*
|
||||
notebooks/scipy2015/SeogiModelMT3Dfor21Dinv/seogiModel_dobs.npy
|
||||
notebooks/MT Script-3D_InversionTest-Copy1.ipynb
|
||||
notebooks/scipy2015/SeogiModelMT3Dfor21Dinv/model3D_zdet1Dinv_paddedMesh.vtr
|
||||
notebooks/scipy2015/SeogiModelMT3Dfor21Dinv/model3D_zxy1Dinv_paddedMesh.vtr
|
||||
notebooks/scipy2015/SeogiModelMT3Dfor21Dinv/model3D_zyx1Dinv_paddedMesh.vtr
|
||||
notebooks/scipy2015/SeogiModelMT3Dfor21Dinv/modelTDpaddedMesh.vtr
|
||||
notebooks/scipy2015/SeogiModelMT3Dfor21Dinv/modelTDuniMesh.vtr
|
||||
|
||||
+15
-6
@@ -1,8 +1,10 @@
|
||||
language: python
|
||||
python:
|
||||
- "2.7"
|
||||
virtualenv:
|
||||
system_site_packages: true
|
||||
- 2.7
|
||||
# virtualenv:
|
||||
# system_site_packages: true
|
||||
|
||||
sudo: false
|
||||
|
||||
# Setup anaconda
|
||||
before_install:
|
||||
@@ -12,12 +14,12 @@ before_install:
|
||||
- export PATH=/home/travis/anaconda/bin:/home/travis/miniconda/bin:$PATH
|
||||
- conda update --yes conda
|
||||
# The next couple lines fix a crash with multiprocessing on Travis and are not specific to using Miniconda
|
||||
- sudo rm -rf /dev/shm
|
||||
- sudo ln -s /run/shm /dev/shm
|
||||
# - sudo rm -rf /dev/shm
|
||||
# - sudo ln -s /run/shm /dev/shm
|
||||
|
||||
# Install packages
|
||||
install:
|
||||
- conda install --yes pip python=$TRAVIS_PYTHON_VERSION numpy scipy matplotlib cython
|
||||
- conda install --yes pip python=$TRAVIS_PYTHON_VERSION numpy scipy matplotlib cython gdal
|
||||
- pip install nose-cov python-coveralls
|
||||
- cd ../
|
||||
- git clone https://github.com/simpeg/simpeg.git
|
||||
@@ -26,6 +28,12 @@ install:
|
||||
- cd ../
|
||||
- echo export PYTHONPATH=$PYTHONPATH:/home/travis/build/simpeg/simpeg >> .bashrc
|
||||
- source .bashrc
|
||||
- git clone https://github.com/simpeg/simpegem.git
|
||||
- cd simpegem/
|
||||
- python setup.py build_ext --inplace
|
||||
- cd ../
|
||||
- echo export PYTHONPATH=$PYTHONPATH:/home/travis/build/simpeg/simpegem >> .bashrc
|
||||
- source .bashrc
|
||||
- cd simpegmt
|
||||
|
||||
# Run test
|
||||
@@ -40,3 +48,4 @@ notifications:
|
||||
email:
|
||||
- rowanc1@gmail.com
|
||||
- gkrosen@gmail.com
|
||||
- lindseyheagy@gmail.com
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,890 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Testing derivaties for 1D MT problem.\n",
|
||||
"\n",
|
||||
"Especially the rx.projectFieldsDeriv"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import SimPEG as simpeg\n",
|
||||
"import simpegEM as simpegem, simpegMT as simpegmt\n",
|
||||
"from SimPEG.Utils import meshTensor\n",
|
||||
"import numpy as np"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"simpegMT.FieldsMT.FieldsMT_1D"
|
||||
]
|
||||
},
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"simpegmt.FieldsMT.FieldsMT_1D"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Setup the problem\n",
|
||||
"sigmaHalf = 1e-2\n",
|
||||
"# Frequency\n",
|
||||
"nFreq = 33\n",
|
||||
"# freqs = np.logspace(3,-3,nFreq)\n",
|
||||
"freqs = np.array([100])\n",
|
||||
"# Make the mesh\n",
|
||||
"ct = 5\n",
|
||||
"air = meshTensor([(ct,25,1.3)])\n",
|
||||
"# coreT0 = meshTensor([(ct,15,1.2)])\n",
|
||||
"# coreT1 = np.kron(meshTensor([(coreT0[-1],15,1.3)]),np.ones((7,)))\n",
|
||||
"core = np.concatenate( ( np.kron(meshTensor([(ct,15,-1.2)]),np.ones((10,))) , meshTensor([(ct,20)]) ) )\n",
|
||||
"bot = meshTensor([(core[0],10,-1.3)])\n",
|
||||
"x0 = -np.array([np.sum(np.concatenate((core,bot)))])\n",
|
||||
"# Change to use no air\n",
|
||||
"m1d = simpeg.Mesh.TensorMesh([np.concatenate((bot,core))], x0=x0)\n",
|
||||
"# Make the model\n",
|
||||
"sigma = np.zeros(m1d.nC) + sigmaHalf\n",
|
||||
"sigma[ m1d.gridCC > 0 ] = 1e-8\n",
|
||||
"\n",
|
||||
"rxList = []\n",
|
||||
"for rxType in ['z1dr','z1di']:\n",
|
||||
" rxList.append(simpegmt.SurveyMT.RxMT(simpeg.mkvc(np.array([0.0]),2).T,rxType))\n",
|
||||
"# Source list\n",
|
||||
"srcList =[]\n",
|
||||
"tD = False\n",
|
||||
"if tD:\n",
|
||||
" for freq in freqs:\n",
|
||||
" srcList.append(simpegmt.SurveyMT.srcMT_polxy_1DhomotD(rxList,freq))\n",
|
||||
"else:\n",
|
||||
" for freq in freqs:\n",
|
||||
" srcList.append(simpegmt.SurveyMT.srcMT_polxy_1Dprimary(rxList,freq))\n",
|
||||
"# Make the survey\n",
|
||||
"survey = simpegmt.SurveyMT.SurveyMT(srcList)\n",
|
||||
"\n",
|
||||
"# Set the problem\n",
|
||||
"problem = simpegmt.ProblemMT1D.eForm_psField(m1d)\n",
|
||||
"problem.sigmaPrimary = sigma\n",
|
||||
"problem.pair(survey)\n",
|
||||
"\n",
|
||||
"# Get the fields\n",
|
||||
"fields = problem.fields(sigma)\n",
|
||||
"\n",
|
||||
"# Project the data\n",
|
||||
"data = survey.projectFields(fields)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"ERROR: No traceback has been produced, nothing to debug.\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"%debug\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"We need calculate this derivative. \n",
|
||||
"\\begin{align}\n",
|
||||
"\\underbrace{\\frac{\\partial P(f(u(m)),m^{fix})}{\\partial f}}_{Rx}\n",
|
||||
"\\end{align}\n",
|
||||
"\n",
|
||||
"Use the rule\n",
|
||||
"\\begin{align}\n",
|
||||
"\\frac{d}{dx}\\left( \\frac{a(x)}{b(x)} \\right) = \\frac{\\frac{d }{dx} a(x) b(x) - a(x)\\frac{d }{dx} b(x) }{ b(x)^2 }\n",
|
||||
"\\end{align}\n",
|
||||
"\n",
|
||||
"In the case of the 1D MT problem the data is calculated as \n",
|
||||
"\\begin{align}\n",
|
||||
"MT1Ddata = P(f(m)) &= \\frac{P_{ex} f_e(src,m)}{P_{bx} f_b(src,m) \\frac{1}{\\mu_0}} = \\frac{P_e u}{P_b f_b(u)} \\\\\n",
|
||||
"\\frac{\\partial P(f(m))}{\\partial u} v &= \\frac{P_e}{P_b \\frac{1}{mu_0} f_b(u)}v - \\frac{P_e u}{\\left(P_b \\frac{1}{mu_0} f_b(u)\\right)^2} P_b \\frac{1}{mu_0} \\frac{d f_b}{du} v\n",
|
||||
"\\end{align}\n",
|
||||
"where u is the fields that we solve for. \n",
|
||||
"\\begin{align}\n",
|
||||
"\\frac{d f_b}{du} = - \\frac{1}{i \\omega} \\nabla \n",
|
||||
"\\end{align}\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {
|
||||
"collapsed": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Unused code &= \\frac{ P_{ex} P_{bx} \\frac{1}{\\mu_0} \\left( f_b(src,m) - f_e(src,m) \\right) } { \\left(P_{bx}f_b(src,m) \\frac{1}{\\mu_0} \\right)^2 }"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"As matrices the formulas above can be written as\n",
|
||||
"\\begin{align}\n",
|
||||
"\\left[ \\frac{\\partial P(f(m))}{\\partial u} v \\right] = \\left[ diag \\left[ \\frac{1}{\\left(P_b \\frac{1}{mu_0} f_b(u)\\right)} \\right] [P_e v] , diag[P_e u] diag \\left[ \\frac{1}{\\left(P_b \\frac{1}{mu_0} f_b(u)\\right)} \\right]^T diag \\left[ \\frac{1}{\\left(P_b \\frac{1}{mu_0} f_b(u)\\right)} \\right] \\left[ P_b \\frac{1}{mu_0} \\frac{d f_b}{du}(v) \\right] \\right]\n",
|
||||
"\\end{align}\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"The adjoint problem is done simliarly\n",
|
||||
"\\begin{align}\n",
|
||||
"\\left[ \\frac{\\partial P(f(m))}{\\partial u} v \\right]^T = [P_e]^T diag \\left[ \\frac{1}{\\left(P_b \\frac{1}{mu_0} f_b(u)\\right)} \\right]^T v - \\left[ P_b \\frac{d f_b}{du} \\frac{1}{mu_0} \\right]^T diag \\left[ \\frac{1}{\\left(P_b \\frac{1}{mu_0} f_b(u)\\right)} \\right] diag \\left[ \\frac{1}{\\left(P_b \\frac{1}{mu_0} f_b(u)\\right)} \\right]^T diag \\left[ P_e u \\right]^T v\n",
|
||||
"\\end{align}\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"metadata": {
|
||||
"collapsed": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# def projectFields(self, src, mesh, u):\n",
|
||||
"# '''\n",
|
||||
"# Project the fields and return the\n",
|
||||
"# '''\n",
|
||||
"\n",
|
||||
"# if self.projType is 'Z1D':\n",
|
||||
"# Pex = mesh.getInterpolationMat(self.locs,'Fx')\n",
|
||||
"# Pbx = mesh.getInterpolationMat(self.locs,'Ex')\n",
|
||||
"# ex = Pex*mkvc(u[src,'e_1d'],2)\n",
|
||||
"# bx = Pbx*mkvc(u[src,'b_1d'],2)/mu_0\n",
|
||||
"# f_part_complex = ex/bx\n",
|
||||
"# real_or_imag = self.projComp\n",
|
||||
"# f_part = getattr(f_part_complex, real_or_imag)\n",
|
||||
"# return f_part"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Initate things for the derivs Test\n",
|
||||
"src = survey.srcList[0]\n",
|
||||
"rx = src.rxList[0]\n",
|
||||
"v = np.random.randn(m1d.nN)\n",
|
||||
"v0 = np.random.randn(m1d.nF+m1d.nE)\n",
|
||||
"u0 = np.random.randn(m1d.nN)+np.random.randn(m1d.nN)*1j\n",
|
||||
"f0 = problem.fieldsPair(m1d,survey)\n",
|
||||
"f0[src,'e_1dSolution'] = u0\n",
|
||||
"# f0[src,'b_1d'] = -1/(1j*simpegem.Utils.EMUtils.omega(src.freq))*m1d.nodalGrad*u0"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "raw",
|
||||
"metadata": {},
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"==================== checkDerivative ====================\n",
|
||||
"iter h |ft-f0| |ft-f0-h*J0*dx| Order\n",
|
||||
"---------------------------------------------------------\n",
|
||||
" 0 1.00e-01 3.089e-04 2.730e-05 nan\n",
|
||||
" 1 1.00e-02 2.841e-05 2.582e-07 2.024\n",
|
||||
" 2 1.00e-03 2.818e-06 2.568e-09 2.002\n",
|
||||
" 3 1.00e-04 2.816e-07 2.567e-11 2.000\n",
|
||||
" 4 1.00e-05 2.816e-08 2.567e-13 2.000\n",
|
||||
"========================= PASS! =========================\n",
|
||||
"The test be workin!\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"True"
|
||||
]
|
||||
},
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Run a test\n",
|
||||
"def fun(u):\n",
|
||||
" f = problem.fieldsPair(m1d,survey)\n",
|
||||
" f[src,'e_1dSolution'] = u\n",
|
||||
" return rx.projectFields(src,m1d,f), lambda t: rx.projectFieldsDeriv(src,m1d,f0,t)\n",
|
||||
"simpeg.Tests.checkDerivative(fun,u0,num=5,plotIt=False)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"array([-0.00285083])"
|
||||
]
|
||||
},
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"rx.projectFieldsDeriv(src,m1d,f0,u0)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"array([[-0.00130618]])"
|
||||
]
|
||||
},
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"rx.projectFields(src,m1d,f0)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Test the Jvec derivative."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"==================== checkDerivative ====================\n",
|
||||
"iter h |ft-f0| |ft-f0-h*J0*dx| Order\n",
|
||||
"---------------------------------------------------------\n",
|
||||
" 0 1.00e-01 1.537e-05 1.005e-07 nan\n",
|
||||
" 1 1.00e-02 1.541e-06 1.008e-09 1.999\n",
|
||||
" 2 1.00e-03 1.541e-07 1.008e-11 2.000\n",
|
||||
" 3 1.00e-04 1.541e-08 1.008e-13 2.000\n",
|
||||
"========================= PASS! =========================\n",
|
||||
"The test be workin!\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"True"
|
||||
]
|
||||
},
|
||||
"execution_count": 12,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# print '%s formulation - %s' % (fdemType, comp)\n",
|
||||
"CONDUCTIVITY = 0.01\n",
|
||||
"m0 = np.log(np.ones(problem.mesh.nC)*CONDUCTIVITY)\n",
|
||||
"# mu = np.log(np.ones(problem.mesh.nC)*MU)\n",
|
||||
"\n",
|
||||
"if True:\n",
|
||||
" m0 = m0 + np.random.randn(problem.mesh.nC)*CONDUCTIVITY*1e-1 \n",
|
||||
"# mu = mu + np.random.randn(prb.mesh.nC)*MU*1e-1\n",
|
||||
"\n",
|
||||
"# prb.mu = mu\n",
|
||||
"# survey = prb.survey\n",
|
||||
"def fun(x):\n",
|
||||
" \n",
|
||||
" return survey.dpred(x), lambda x: problem.Jvec(m0, x)\n",
|
||||
"simpeg.Tests.checkDerivative(fun, m0, num=4, plotIt=False)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"ERROR: No traceback has been produced, nothing to debug.\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"%debug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 14,
|
||||
"metadata": {
|
||||
"collapsed": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"### Adjoint test"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"We have \n",
|
||||
"\\begin{align}\n",
|
||||
"Jvec =&"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 15,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Adjoint e formulation - projectFieldsDeriv\n",
|
||||
"0.000177264079929 0.000177264079929 3.52365706058e-19 1e-07 True\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"True"
|
||||
]
|
||||
},
|
||||
"execution_count": 15,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Run a test\n",
|
||||
"TOL = 1e-4\n",
|
||||
"FLR = 1e-20\n",
|
||||
"\n",
|
||||
"def projectFieldsAdjointTest(fdemType, comp):\n",
|
||||
" print 'Adjoint %s formulation - %s' % (fdemType, comp)\n",
|
||||
"\n",
|
||||
" m = np.log(np.ones(problem.mesh.nC)*0.01)\n",
|
||||
" if True:\n",
|
||||
" m = m + np.random.randn(problem.mesh.nC)*0.01*1e-1 \n",
|
||||
"\n",
|
||||
" u = problem.fields(m)\n",
|
||||
" v = np.random.randn(1)#+np.random.randn(1)*1j\n",
|
||||
" # print prb.PropMap.PropModel.nP\n",
|
||||
" w = np.random.randn(m1d.nN)+np.random.randn(m1d.nN)*1j\n",
|
||||
"\n",
|
||||
" vJw = v.dot(rx.projectFieldsDeriv(src,m1d,f0,w))\n",
|
||||
" wJtv = w.dot(rx.projectFieldsDeriv(src,m1d,f0,v,adjoint=True)).real\n",
|
||||
" tol = np.max([TOL*(10**int(np.log10(np.abs(vJw)))),FLR]) \n",
|
||||
" print vJw, wJtv, vJw - wJtv, tol, np.abs(vJw - wJtv) < tol\n",
|
||||
" return np.abs(vJw - wJtv) < tol\n",
|
||||
"projectFieldsAdjointTest('e','projectFieldsDeriv')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 21,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Adjoint test e formulation - getADeriv_m\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"ename": "KeyError",
|
||||
"evalue": "'Source does not have a uid: e_1dSolution'",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
||||
"\u001b[1;31mKeyError\u001b[0m Traceback (most recent call last)",
|
||||
"\u001b[1;32m<ipython-input-21-4c7e7058b8e9>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 20\u001b[0m \u001b[1;32mprint\u001b[0m \u001b[0mvJw\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mwJtv\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mvJw\u001b[0m \u001b[1;33m-\u001b[0m \u001b[0mwJtv\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtol\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mabs\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mvJw\u001b[0m \u001b[1;33m-\u001b[0m \u001b[0mwJtv\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m<\u001b[0m \u001b[0mtol\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 21\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mabs\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mvJw\u001b[0m \u001b[1;33m-\u001b[0m \u001b[0mwJtv\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m<\u001b[0m \u001b[0mtol\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 22\u001b[1;33m \u001b[0mgetADeriv_mAdjointTest\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
|
||||
"\u001b[1;32m<ipython-input-21-4c7e7058b8e9>\u001b[0m in \u001b[0;36mgetADeriv_mAdjointTest\u001b[1;34m()\u001b[0m\n\u001b[0;32m 15\u001b[0m \u001b[0mw\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrandom\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrandn\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mm1d\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mnC\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;31m#+np.random.randn(m1d.nN)*1j\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 16\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 17\u001b[1;33m \u001b[0mvJw\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mv\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdot\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mproblem\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mgetADeriv_m\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mfreq\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mf0\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mw\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 18\u001b[0m \u001b[0mwJtv\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mw\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdot\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mproblem\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mgetADeriv_m\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mfreq\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mf0\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mv\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0madjoint\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mTrue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 19\u001b[0m \u001b[0mtol\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmax\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mTOL\u001b[0m\u001b[1;33m*\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m10\u001b[0m\u001b[1;33m**\u001b[0m\u001b[0mint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mlog10\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mabs\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mvJw\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mFLR\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
||||
"\u001b[1;32m/media/gudni/ExtraDrive1/Codes/python/simpegmt/simpegMT/ProblemMT1D/Problems.py\u001b[0m in \u001b[0;36mgetADeriv_m\u001b[1;34m(self, freq, u, v, adjoint)\u001b[0m\n\u001b[0;32m 67\u001b[0m \u001b[0mMeMui\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmesh\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mgetEdgeInnerProduct\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m1.0\u001b[0m\u001b[1;33m/\u001b[0m\u001b[0mmu_0\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 68\u001b[0m \u001b[1;31m#\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 69\u001b[1;33m \u001b[0mu_src\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mu\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'e_1dSolution'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 70\u001b[0m \u001b[0mdMf_dsig\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmesh\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mgetFaceInnerProductDeriv\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcurModel\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msigma\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mu_src\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m*\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcurModel\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msigmaDeriv\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 71\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0madjoint\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
||||
"\u001b[1;32m/media/gudni/ExtraDrive1/Codes/python/simpeg/SimPEG/Fields.pyc\u001b[0m in \u001b[0;36m__getitem__\u001b[1;34m(self, key)\u001b[0m\n\u001b[0;32m 150\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 151\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0m__getitem__\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 152\u001b[1;33m \u001b[0mind\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mname\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_indexAndNameFromKey\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'get'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 153\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mname\u001b[0m \u001b[1;32mis\u001b[0m \u001b[0mNone\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 154\u001b[0m \u001b[0mout\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m{\u001b[0m\u001b[1;33m}\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
||||
"\u001b[1;32m/media/gudni/ExtraDrive1/Codes/python/simpeg/SimPEG/Fields.pyc\u001b[0m in \u001b[0;36m_indexAndNameFromKey\u001b[1;34m(self, key, accessType)\u001b[0m\n\u001b[0;32m 131\u001b[0m \u001b[0msrcTestList\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mname\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mkey\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 132\u001b[0m \u001b[0mname\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_nameIndex\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mname\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0maccessType\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 133\u001b[1;33m \u001b[0mind\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_srcIndex\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msrcTestList\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 134\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mind\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mname\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 135\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
|
||||
"\u001b[1;32m/media/gudni/ExtraDrive1/Codes/python/simpeg/SimPEG/Fields.pyc\u001b[0m in \u001b[0;36m_srcIndex\u001b[1;34m(self, srcTestList)\u001b[0m\n\u001b[0;32m 100\u001b[0m \u001b[0mind\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0msrcTestList\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 101\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 102\u001b[1;33m \u001b[0mind\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msurvey\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mgetSourceIndex\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msrcTestList\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 103\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mind\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 104\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
|
||||
"\u001b[1;32m/media/gudni/ExtraDrive1/Codes/python/simpeg/SimPEG/Survey.pyc\u001b[0m in \u001b[0;36mgetSourceIndex\u001b[1;34m(self, sources)\u001b[0m\n\u001b[0;32m 339\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0msrc\u001b[0m \u001b[1;32min\u001b[0m \u001b[0msources\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 340\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mgetattr\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msrc\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;34m'uid'\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mNone\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mis\u001b[0m \u001b[0mNone\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 341\u001b[1;33m \u001b[1;32mraise\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'Source does not have a uid: %s'\u001b[0m\u001b[1;33m%\u001b[0m\u001b[0mstr\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msrc\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 342\u001b[0m \u001b[0minds\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mmap\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;32mlambda\u001b[0m \u001b[0msrc\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_sourceOrder\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msrc\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0muid\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mNone\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0msources\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 343\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mNone\u001b[0m \u001b[1;32min\u001b[0m \u001b[0minds\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
||||
"\u001b[1;31mKeyError\u001b[0m: 'Source does not have a uid: e_1dSolution'"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Run a test\n",
|
||||
"TOL = 1e-4\n",
|
||||
"FLR = 1e-20\n",
|
||||
"\n",
|
||||
"def getADeriv_mAdjointTest():\n",
|
||||
" print 'Adjoint test e formulation - getADeriv_m' \n",
|
||||
"\n",
|
||||
" m = np.log(np.ones(problem.mesh.nC)*0.01)\n",
|
||||
" if True:\n",
|
||||
" m = m + np.random.randn(problem.mesh.nC)*0.01*1e-1 \n",
|
||||
"\n",
|
||||
" u = problem.fields(m)\n",
|
||||
" v = np.random.randn(m1d.nN)#+np.random.randn(1)*1j\n",
|
||||
" # print prb.PropMap.PropModel.nP\n",
|
||||
" w = np.random.randn(m1d.nC)#+np.random.randn(m1d.nN)*1j\n",
|
||||
"\n",
|
||||
" vJw = v.dot(problem.getADeriv_m(freq,f0,w))\n",
|
||||
" wJtv = w.dot(problem.getADeriv_m(freq,f0,v,adjoint=True))\n",
|
||||
" tol = np.max([TOL*(10**int(np.log10(np.abs(vJw)))),FLR]) \n",
|
||||
" print vJw, wJtv, vJw - wJtv, tol, np.abs(vJw - wJtv) < tol\n",
|
||||
" return np.abs(vJw - wJtv) < tol\n",
|
||||
"getADeriv_mAdjointTest()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 17,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"> \u001b[1;32m/media/gudni/ExtraDrive1/Codes/python/simpegmt/simpegMT/ProblemMT1D/Problems.py\u001b[0m(69)\u001b[0;36mgetADeriv_m\u001b[1;34m()\u001b[0m\n",
|
||||
"\u001b[1;32m 68 \u001b[1;33m \u001b[1;31m#\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
||||
"\u001b[0m\u001b[1;32m---> 69 \u001b[1;33m \u001b[0mu_src\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mu\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'e_1dSolution'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
||||
"\u001b[0m\u001b[1;32m 70 \u001b[1;33m \u001b[0mdMf_dsig\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmesh\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mgetFaceInnerProductDeriv\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcurModel\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msigma\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mu_src\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m*\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcurModel\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msigmaDeriv\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
||||
"\u001b[0m\n",
|
||||
"ipdb> u\n",
|
||||
"> \u001b[1;32m<ipython-input-16-0d25a7e16094>\u001b[0m(17)\u001b[0;36mgetADeriv_mAdjointTest\u001b[1;34m()\u001b[0m\n",
|
||||
"\u001b[1;32m 16 \u001b[1;33m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
||||
"\u001b[0m\u001b[1;32m---> 17 \u001b[1;33m \u001b[0mvJw\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mv\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdot\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mproblem\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mgetADeriv_m\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mfreq\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mu0\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mw\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
||||
"\u001b[0m\u001b[1;32m 18 \u001b[1;33m \u001b[0mwJtv\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mw\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdot\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mproblem\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mgetADeriv_m\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mfreq\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mu0\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mv\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0madjoint\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mTrue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
||||
"\u001b[0m\n",
|
||||
"ipdb> d\n",
|
||||
"> \u001b[1;32m/media/gudni/ExtraDrive1/Codes/python/simpegmt/simpegMT/ProblemMT1D/Problems.py\u001b[0m(69)\u001b[0;36mgetADeriv_m\u001b[1;34m()\u001b[0m\n",
|
||||
"\u001b[1;32m 68 \u001b[1;33m \u001b[1;31m#\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
||||
"\u001b[0m\u001b[1;32m---> 69 \u001b[1;33m \u001b[0mu_src\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mu\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'e_1dSolution'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
||||
"\u001b[0m\u001b[1;32m 70 \u001b[1;33m \u001b[0mdMf_dsig\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmesh\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mgetFaceInnerProductDeriv\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcurModel\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msigma\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mu_src\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m*\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcurModel\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msigmaDeriv\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
||||
"\u001b[0m\n",
|
||||
"ipdb> p u\n",
|
||||
"array([ 7.09826705e-01 -3.42993400e-01j,\n",
|
||||
" 2.06495724e-02 -1.13236591e+00j,\n",
|
||||
" 7.19940065e-01 +6.18299116e-01j,\n",
|
||||
" -3.76573540e-01 +9.09687373e-01j,\n",
|
||||
" -5.96166731e-01 +2.23309643e-01j,\n",
|
||||
" 3.30533731e-01 +7.98068064e-01j,\n",
|
||||
" -1.41356795e+00 -1.74137927e-01j,\n",
|
||||
" 1.51554175e+00 -2.16363375e-01j,\n",
|
||||
" 1.59469627e+00 -1.87971566e+00j,\n",
|
||||
" -5.54637698e-01 -1.01936458e+00j,\n",
|
||||
" 1.01869865e+00 +8.33443055e-01j,\n",
|
||||
" -4.92616671e-01 -1.97036224e+00j,\n",
|
||||
" 1.00389102e+00 -1.52567261e-01j,\n",
|
||||
" 7.90254779e-01 -5.68065046e-01j,\n",
|
||||
" 9.17329964e-01 -1.18879097e+00j,\n",
|
||||
" -1.38317362e+00 -2.17789273e+00j,\n",
|
||||
" 2.58324368e-01 -1.51003598e+00j,\n",
|
||||
" -2.04803634e+00 -1.44299943e-01j,\n",
|
||||
" 3.33011285e+00 +1.52905384e+00j,\n",
|
||||
" 2.91429972e-01 -1.91849967e+00j,\n",
|
||||
" -1.10273784e+00 -8.65794290e-01j,\n",
|
||||
" -2.80103156e-01 -1.42653192e+00j,\n",
|
||||
" -9.81404885e-01 +9.06845144e-02j,\n",
|
||||
" 6.37579045e-01 +3.84148006e-01j,\n",
|
||||
" -6.83597988e-01 +6.91187965e-01j,\n",
|
||||
" -8.98575981e-01 +3.80347476e-02j,\n",
|
||||
" 1.02647319e+00 -1.13876879e-01j,\n",
|
||||
" 8.28006255e-01 -9.95903406e-01j,\n",
|
||||
" 3.53931083e-01 -2.80188697e-01j,\n",
|
||||
" -1.09339690e+00 +1.43646692e+00j,\n",
|
||||
" 2.59276626e+00 +4.09662561e-01j,\n",
|
||||
" -5.97873868e-01 -5.23852065e-01j,\n",
|
||||
" 8.87054287e-01 -1.69872744e+00j,\n",
|
||||
" 2.29767481e-01 -5.88143928e-01j,\n",
|
||||
" -6.97610315e-01 +5.68810360e-01j,\n",
|
||||
" -4.47049016e-01 +3.29354463e-01j,\n",
|
||||
" -3.31498311e-01 -8.27120276e-01j,\n",
|
||||
" 1.57689998e-01 +6.68378872e-01j,\n",
|
||||
" 9.47018631e-02 +2.60180446e-01j,\n",
|
||||
" -4.59177257e-01 -7.66896049e-01j,\n",
|
||||
" -1.16791204e+00 +4.20585804e-01j,\n",
|
||||
" 2.72405147e-01 +3.48079787e-01j,\n",
|
||||
" -2.45880514e-02 +1.90226778e-01j,\n",
|
||||
" -7.03428363e-01 +1.20531568e+00j,\n",
|
||||
" 1.60362217e+00 +6.88472259e-01j,\n",
|
||||
" -5.49144335e-01 +6.96208292e-01j,\n",
|
||||
" -9.83200346e-01 -1.15726575e+00j,\n",
|
||||
" 1.22826524e+00 -8.58070855e-01j,\n",
|
||||
" -5.99020439e-01 -2.19182124e+00j,\n",
|
||||
" -5.69992871e-01 +1.68586900e+00j,\n",
|
||||
" 9.26752644e-01 +1.05767829e+00j,\n",
|
||||
" 8.64247444e-01 +1.51282356e-01j,\n",
|
||||
" -6.24547862e-01 -1.54517937e+00j,\n",
|
||||
" -1.72043526e+00 +1.91659834e+00j,\n",
|
||||
" -1.84501951e+00 -2.40165623e-01j,\n",
|
||||
" 1.15210121e+00 -1.19627222e+00j,\n",
|
||||
" -3.93036395e-01 -1.94918396e+00j,\n",
|
||||
" -1.18266273e+00 -5.24652722e-01j,\n",
|
||||
" 2.67461628e-01 -8.07279138e-01j,\n",
|
||||
" -1.56363641e+00 +1.59257615e-03j,\n",
|
||||
" -3.17211883e-01 -3.23379690e+00j,\n",
|
||||
" -1.08658939e-01 -8.66079039e-01j,\n",
|
||||
" -9.30350013e-01 -1.22668219e+00j,\n",
|
||||
" -1.07263137e+00 -5.56847000e-02j,\n",
|
||||
" 1.27878013e+00 -1.34173537e+00j,\n",
|
||||
" 7.91441492e-01 +6.42111414e-01j,\n",
|
||||
" -2.60121575e+00 -1.08140886e+00j,\n",
|
||||
" -1.15027808e+00 -4.47110142e-01j,\n",
|
||||
" -5.69747800e-01 +2.34065916e-01j,\n",
|
||||
" 1.52155089e+00 -5.80340775e-01j,\n",
|
||||
" 2.50052750e-01 -6.58793179e-01j,\n",
|
||||
" 2.96944135e-01 +1.27455206e+00j,\n",
|
||||
" 9.18939766e-01 -4.58122761e-01j,\n",
|
||||
" 4.90015531e-01 -8.86288179e-01j,\n",
|
||||
" -1.65155083e+00 -6.57733967e-01j,\n",
|
||||
" 9.72148169e-01 -1.19446820e+00j,\n",
|
||||
" 2.08365350e+00 -1.53585595e-01j,\n",
|
||||
" -4.11101072e-01 +1.01418536e+00j,\n",
|
||||
" 9.72580562e-01 -2.20470840e-01j,\n",
|
||||
" 1.72922147e-01 -6.86360934e-01j,\n",
|
||||
" 3.80255034e-01 +1.96862619e-01j,\n",
|
||||
" -1.53628572e+00 +5.31946011e-01j,\n",
|
||||
" -4.65939167e-01 +9.11725611e-01j,\n",
|
||||
" -1.06390365e+00 -3.07658816e-02j,\n",
|
||||
" -2.40734296e+00 -7.60530882e-01j,\n",
|
||||
" 1.28242272e+00 +3.32085973e+00j,\n",
|
||||
" 3.17004751e+00 +1.62654811e+00j,\n",
|
||||
" -8.49758476e-01 +9.86658359e-01j,\n",
|
||||
" 4.99578557e-01 +4.01392488e-01j,\n",
|
||||
" -9.48695998e-01 +4.04322381e-01j,\n",
|
||||
" 1.75371116e-01 +7.85458813e-01j,\n",
|
||||
" 4.90232886e-01 -1.39280042e-01j,\n",
|
||||
" -2.31430252e-01 -8.44065839e-01j,\n",
|
||||
" -1.02319133e+00 +1.90560784e+00j,\n",
|
||||
" 1.08940667e+00 +1.63046186e+00j,\n",
|
||||
" -4.34233324e-01 +2.90439312e-01j,\n",
|
||||
" 4.47622371e-01 +1.26507976e+00j,\n",
|
||||
" -2.07317470e+00 -2.21558532e+00j,\n",
|
||||
" -3.19553487e-01 -9.19210427e-01j,\n",
|
||||
" 6.09870390e-01 +3.05692898e-01j,\n",
|
||||
" 4.92081860e-01 -2.18326059e-01j,\n",
|
||||
" 1.48544627e+00 -2.02054490e-01j,\n",
|
||||
" -1.59612367e-01 +7.90853777e-02j,\n",
|
||||
" 2.85854411e-01 +2.16567814e-01j,\n",
|
||||
" 5.28063071e-01 +2.08838949e+00j,\n",
|
||||
" 6.17580558e-01 +9.90748539e-01j,\n",
|
||||
" -2.64539211e-01 +1.16598665e+00j,\n",
|
||||
" -1.07357542e+00 -7.58002064e-01j,\n",
|
||||
" 6.13399713e-02 +2.52338250e+00j,\n",
|
||||
" -4.84180135e-01 -1.45046020e+00j,\n",
|
||||
" -6.57519374e-01 -1.52719059e+00j,\n",
|
||||
" -1.54949084e-01 -7.64796563e-01j,\n",
|
||||
" -2.01172915e-02 +1.07377565e+00j,\n",
|
||||
" 2.19840636e-01 +6.89622678e-01j,\n",
|
||||
" -2.64578500e+00 +1.46933966e+00j,\n",
|
||||
" 1.22168696e+00 +2.33458454e-01j,\n",
|
||||
" 2.71303177e+00 +2.77858685e-01j,\n",
|
||||
" 4.39426665e-01 +1.79924695e-01j,\n",
|
||||
" -1.73858667e+00 -3.03473636e-01j,\n",
|
||||
" 2.68736300e-01 +8.32359634e-01j,\n",
|
||||
" 2.57517784e+00 +1.88097576e-01j,\n",
|
||||
" 2.76775469e-01 -6.49891901e-01j,\n",
|
||||
" -9.87790301e-01 +4.50328269e-01j,\n",
|
||||
" 9.19033669e-01 +1.01453748e+00j,\n",
|
||||
" -1.35706747e+00 +5.90240590e-01j,\n",
|
||||
" 6.60118738e-01 +5.10361208e-01j,\n",
|
||||
" -2.17652642e-01 -4.26632365e-01j,\n",
|
||||
" -1.39163540e+00 +9.12739752e-01j,\n",
|
||||
" -1.76241829e+00 -1.04835908e+00j,\n",
|
||||
" -7.28279529e-01 +2.75961750e-01j,\n",
|
||||
" -1.32043513e+00 -3.28790183e-01j,\n",
|
||||
" 5.88227093e-01 +9.41865970e-01j,\n",
|
||||
" 1.97695607e+00 +1.04535450e+00j,\n",
|
||||
" -3.02599128e+00 +1.02031744e+00j,\n",
|
||||
" -1.34308763e+00 -4.48222977e-01j,\n",
|
||||
" -1.86687861e+00 +2.26767568e+00j,\n",
|
||||
" 5.61472023e-01 -5.28652462e-01j,\n",
|
||||
" -5.26747946e-01 +2.75545054e-01j,\n",
|
||||
" 6.16116514e-01 +3.41765793e-01j,\n",
|
||||
" 1.38709750e+00 +5.87537003e-01j,\n",
|
||||
" -2.27923203e-01 +7.19317677e-01j,\n",
|
||||
" -8.66404713e-01 -1.80932081e-01j,\n",
|
||||
" -4.58146668e-01 +1.75955171e+00j,\n",
|
||||
" -5.12526647e-01 -1.91939928e-01j,\n",
|
||||
" -6.26532699e-01 -5.71301355e-01j,\n",
|
||||
" -3.35566040e-01 -5.06173544e-01j,\n",
|
||||
" -3.86124497e-01 -8.00560567e-01j,\n",
|
||||
" 2.47252265e+00 +3.83928843e-01j,\n",
|
||||
" 3.35561169e-01 +1.19309445e+00j,\n",
|
||||
" -6.19075444e-01 -1.19021628e+00j,\n",
|
||||
" -1.17335297e+00 +5.80500783e-01j,\n",
|
||||
" -2.35111248e-01 -1.59785495e+00j,\n",
|
||||
" -1.24819583e-01 -8.05281256e-01j,\n",
|
||||
" -9.18606131e-01 -1.25312332e-01j,\n",
|
||||
" 3.14400972e-01 +1.18650079e+00j,\n",
|
||||
" 6.50630049e-01 -6.99853497e-01j,\n",
|
||||
" 1.28269722e+00 -1.29832850e+00j,\n",
|
||||
" 2.07880202e-01 +2.56385692e-02j,\n",
|
||||
" -1.45089461e+00 -9.35093103e-01j,\n",
|
||||
" 6.84146951e-01 +7.74422758e-01j,\n",
|
||||
" 9.45439196e-01 -3.50695577e-01j,\n",
|
||||
" 1.00057580e+00 -1.27412936e+00j,\n",
|
||||
" -2.01665427e-01 +1.73591867e+00j,\n",
|
||||
" 1.76623768e+00 -1.42964638e+00j,\n",
|
||||
" 1.12282181e+00 +9.02767375e-01j,\n",
|
||||
" -2.22663798e+00 +7.34672692e-02j,\n",
|
||||
" 8.26230180e-02 -7.46601441e-01j,\n",
|
||||
" -4.92810641e-01 -5.49544995e-01j,\n",
|
||||
" 1.06703148e-01 +1.70461156e+00j,\n",
|
||||
" -6.84949746e-01 -1.46950185e-01j,\n",
|
||||
" 1.47509281e+00 +8.77421590e-01j,\n",
|
||||
" -9.83722735e-03 -6.30597166e-01j,\n",
|
||||
" 2.36006569e-03 +2.12883413e-01j,\n",
|
||||
" -3.67899785e-01 -9.95508241e-02j,\n",
|
||||
" 1.26752410e+00 +2.49370098e-01j,\n",
|
||||
" -1.19439605e+00 +2.94935402e-01j,\n",
|
||||
" -2.28617888e+00 +5.70564449e-02j,\n",
|
||||
" 3.95617530e-02 -2.80995512e-01j,\n",
|
||||
" -7.51027805e-01 -8.14567233e-01j,\n",
|
||||
" -1.24160227e+00 -4.13553574e-01j, -4.76626111e-01 +4.16480574e-01j])\n",
|
||||
"ipdb> u_src\n",
|
||||
"*** NameError: name 'u_src' is not defined\n",
|
||||
"ipdb> c\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"%debug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 18,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Adjoint test e formulation - getRHSDeriv_m\n",
|
||||
"(-10077.7224119-28916.4723594j) (-10077.7224119-28916.4723594j) (1.81898940355e-12-3.63797880709e-12j) 1.0 True\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"True"
|
||||
]
|
||||
},
|
||||
"execution_count": 18,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Run a test\n",
|
||||
"TOL = 1e-4\n",
|
||||
"FLR = 1e-20\n",
|
||||
"\n",
|
||||
"def getRHSDeriv_mAdjointTest():\n",
|
||||
" print 'Adjoint test e formulation - getRHSDeriv_m'\n",
|
||||
"\n",
|
||||
" m = np.log(np.ones(problem.mesh.nC)*0.01)\n",
|
||||
" if True:\n",
|
||||
" m = m + np.random.randn(problem.mesh.nC)*0.01*1e-1 \n",
|
||||
"\n",
|
||||
" u = problem.fields(m)\n",
|
||||
" v = np.random.randn(m1d.nN)#+np.random.randn(1)*1j\n",
|
||||
" # print prb.PropMap.PropModel.nP\n",
|
||||
" w = np.random.randn(m1d.nC)#+np.random.randn(m1d.nN)*1j\n",
|
||||
"\n",
|
||||
" vJw = v.dot(problem.getRHSDeriv_m(freq,w))\n",
|
||||
" wJtv = w.dot(problem.getRHSDeriv_m(freq,v,adjoint=True))\n",
|
||||
" tol = np.max([TOL*(10**int(np.log10(np.abs(vJw)))),FLR]) \n",
|
||||
" print vJw, wJtv, vJw - wJtv, tol, np.abs(vJw - wJtv) < tol\n",
|
||||
" return np.abs(vJw - wJtv) < tol\n",
|
||||
"getRHSDeriv_mAdjointTest( )"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"simpeg.mkvc(np.random.randn(survey.nD)+np.random.randn(survey.nD)*1j,2)\n",
|
||||
"\n",
|
||||
"print survey.nD"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 19,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"TOL = 1e-4\n",
|
||||
"FLR = 1e-20\n",
|
||||
"\n",
|
||||
"def JvecAdjointTest():\n",
|
||||
" print 'Adjoint e formulation - Jvec' \n",
|
||||
"\n",
|
||||
" m = np.log(np.ones(problem.mesh.nC)*0.01)\n",
|
||||
" if True:\n",
|
||||
" m = m + np.random.randn(problem.mesh.nC)*0.01*1e-1 \n",
|
||||
"\n",
|
||||
" u = problem.fields(m)\n",
|
||||
"\n",
|
||||
" v = np.random.rand(survey.nD)\n",
|
||||
" # print prb.PropMap.PropModel.nP\n",
|
||||
" w = np.random.rand(problem.mesh.nC)\n",
|
||||
"\n",
|
||||
" vJw = v.dot(problem.Jvec(m, w, u))\n",
|
||||
" wJtv = w.dot(problem.Jtvec(m, v, u))\n",
|
||||
" tol = np.max([TOL*(10**int(np.log10(np.abs(vJw)))),FLR]) \n",
|
||||
" print vJw, wJtv, vJw - wJtv, tol, np.abs(vJw - wJtv) < tol\n",
|
||||
" return np.abs(vJw - wJtv) < tol"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 20,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Adjoint e formulation - Jvec\n",
|
||||
"1.09508355274e-05 1.09508355274e-05 -1.01643953671e-20 1e-08 True\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"True"
|
||||
]
|
||||
},
|
||||
"execution_count": 20,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"JvecAdjointTest()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 2",
|
||||
"language": "python",
|
||||
"name": "python2"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 16,
|
||||
"execution_count": 6,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -22,7 +22,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 17,
|
||||
"execution_count": 7,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -39,7 +39,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 18,
|
||||
"execution_count": 8,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -62,7 +62,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 19,
|
||||
"execution_count": 9,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -70,10 +70,10 @@
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"[<matplotlib.lines.Line2D at 0x7f28e1428f50>]"
|
||||
"[<matplotlib.lines.Line2D at 0x7f2e0ac0b590>]"
|
||||
]
|
||||
},
|
||||
"execution_count": 19,
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
},
|
||||
@@ -186,7 +186,7 @@
|
||||
"ZSzcklQZC7ckVcbCLUmVsXBLUmX+H3zfa/Qjde8mAAAAAElFTkSuQmCC\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"<matplotlib.figure.Figure at 0x7f28e25e0050>"
|
||||
"<matplotlib.figure.Figure at 0x7f2e0b5d9810>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
@@ -199,7 +199,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 20,
|
||||
"execution_count": 10,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -217,7 +217,7 @@
|
||||
" 7888.671875 , 11733.0078125 , 17499.51171875])"
|
||||
]
|
||||
},
|
||||
"execution_count": 20,
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -228,7 +228,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 21,
|
||||
"execution_count": 28,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -249,7 +249,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 22,
|
||||
"execution_count": 29,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -260,7 +260,7 @@
|
||||
"(12836609.712174654+24128916.329733729j)"
|
||||
]
|
||||
},
|
||||
"execution_count": 22,
|
||||
"execution_count": 29,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -271,7 +271,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 23,
|
||||
"execution_count": 30,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -343,7 +343,7 @@
|
||||
" 1.00000000e+00 -0.00000000e+00j]])"
|
||||
]
|
||||
},
|
||||
"execution_count": 23,
|
||||
"execution_count": 30,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -354,7 +354,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 24,
|
||||
"execution_count": 31,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -362,11 +362,11 @@
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"[<matplotlib.lines.Line2D at 0x7f28e1642950>,\n",
|
||||
" <matplotlib.lines.Line2D at 0x7f28e1642410>]"
|
||||
"[<matplotlib.lines.Line2D at 0x7f2e0a452750>,\n",
|
||||
" <matplotlib.lines.Line2D at 0x7f2e0a4529d0>]"
|
||||
]
|
||||
},
|
||||
"execution_count": 24,
|
||||
"execution_count": 31,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
},
|
||||
@@ -562,7 +562,7 @@
|
||||
"ThxmZlYrThxmZlYrThxmZlYr/x/lWzp+eZujggAAAABJRU5ErkJggg==\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"<matplotlib.figure.Figure at 0x7f28e149ae50>"
|
||||
"<matplotlib.figure.Figure at 0x7f2e0a4dcd10>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
@@ -576,7 +576,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 25,
|
||||
"execution_count": 32,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -584,10 +584,10 @@
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"[<matplotlib.lines.Line2D at 0x7f28e24abf10>]"
|
||||
"[<matplotlib.lines.Line2D at 0x7f2e0a397350>]"
|
||||
]
|
||||
},
|
||||
"execution_count": 25,
|
||||
"execution_count": 32,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
},
|
||||
@@ -788,7 +788,7 @@
|
||||
"ZlYRFw4zM6uIC4eZmVXEhcPMzCriwmFmZhVx4TAzs4r8f6jZeSiIHLknAAAAAElFTkSuQmCC\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"<matplotlib.figure.Figure at 0x7f28e166af10>"
|
||||
"<matplotlib.figure.Figure at 0x7f2e0a4dc2d0>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
@@ -801,7 +801,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 26,
|
||||
"execution_count": 33,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -809,11 +809,11 @@
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"[<matplotlib.lines.Line2D at 0x7f28e13c1750>,\n",
|
||||
" <matplotlib.lines.Line2D at 0x7f28e13c19d0>]"
|
||||
"[<matplotlib.lines.Line2D at 0x7f2e0a2dc1d0>,\n",
|
||||
" <matplotlib.lines.Line2D at 0x7f2e0a2dc450>]"
|
||||
]
|
||||
},
|
||||
"execution_count": 26,
|
||||
"execution_count": 33,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
},
|
||||
@@ -1048,7 +1048,7 @@
|
||||
"c865pPGk4pxzLmk8qTjnnEsaTyrOOeeS5v8Bn8/HW3Alj/EAAAAASUVORK5CYII=\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"<matplotlib.figure.Figure at 0x7f28e1672450>"
|
||||
"<matplotlib.figure.Figure at 0x7f2e0a4dcb90>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
@@ -1061,7 +1061,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 27,
|
||||
"execution_count": 34,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -1077,10 +1077,10 @@
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"[<matplotlib.lines.Line2D at 0x7f28e12fd450>]"
|
||||
"[<matplotlib.lines.Line2D at 0x7f2e0a224050>]"
|
||||
]
|
||||
},
|
||||
"execution_count": 27,
|
||||
"execution_count": 34,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
},
|
||||
@@ -1252,7 +1252,7 @@
|
||||
"rkJggg==\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"<matplotlib.figure.Figure at 0x7f28e13589d0>"
|
||||
"<matplotlib.figure.Figure at 0x7f2e0a4dc310>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
@@ -1265,7 +1265,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 28,
|
||||
"execution_count": 35,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -1273,11 +1273,11 @@
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"[<matplotlib.lines.Line2D at 0x7f28e1261d50>,\n",
|
||||
" <matplotlib.lines.Line2D at 0x7f28e1238110>]"
|
||||
"[<matplotlib.lines.Line2D at 0x7f2e0a18c850>,\n",
|
||||
" <matplotlib.lines.Line2D at 0x7f2e0a15cc50>]"
|
||||
]
|
||||
},
|
||||
"execution_count": 28,
|
||||
"execution_count": 35,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
},
|
||||
@@ -1485,7 +1485,7 @@
|
||||
"5P8DEIvS62qo2M0AAAAASUVORK5CYII=\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"<matplotlib.figure.Figure at 0x7f28e1293c90>"
|
||||
"<matplotlib.figure.Figure at 0x7f2e0a27e310>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
@@ -1498,7 +1498,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 29,
|
||||
"execution_count": 36,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -1506,10 +1506,10 @@
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"[<matplotlib.lines.Line2D at 0x7f28e1042c50>]"
|
||||
"[<matplotlib.lines.Line2D at 0x7f2e0a77b990>]"
|
||||
]
|
||||
},
|
||||
"execution_count": 29,
|
||||
"execution_count": 36,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
},
|
||||
@@ -1689,7 +1689,7 @@
|
||||
"rkJggg==\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"<matplotlib.figure.Figure at 0x7f28e11d9d50>"
|
||||
"<matplotlib.figure.Figure at 0x7f2e0a1b9e90>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
@@ -1702,7 +1702,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 30,
|
||||
"execution_count": 37,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -1729,7 +1729,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 31,
|
||||
"execution_count": 38,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -1740,7 +1740,7 @@
|
||||
"(30,)"
|
||||
]
|
||||
},
|
||||
"execution_count": 31,
|
||||
"execution_count": 38,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -1751,7 +1751,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 32,
|
||||
"execution_count": 25,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -1762,7 +1762,7 @@
|
||||
"31"
|
||||
]
|
||||
},
|
||||
"execution_count": 32,
|
||||
"execution_count": 25,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -1773,7 +1773,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 33,
|
||||
"execution_count": 26,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -1781,11 +1781,11 @@
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"[<matplotlib.lines.Line2D at 0x7f28e0f08c90>,\n",
|
||||
" <matplotlib.lines.Line2D at 0x7f28e0f08f10>]"
|
||||
"[<matplotlib.lines.Line2D at 0x7f2e0a501b10>,\n",
|
||||
" <matplotlib.lines.Line2D at 0x7f2e0a501d90>]"
|
||||
]
|
||||
},
|
||||
"execution_count": 33,
|
||||
"execution_count": 26,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
},
|
||||
@@ -1985,7 +1985,7 @@
|
||||
"AABJRU5ErkJggg==\n"
|
||||
],
|
||||
"text/plain": [
|
||||
"<matplotlib.figure.Figure at 0x7f28e0fdce10>"
|
||||
"<matplotlib.figure.Figure at 0x7f2e0a5fe5d0>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
@@ -1998,7 +1998,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 34,
|
||||
"execution_count": 27,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -2016,7 +2016,7 @@
|
||||
" 9810.83984375, 14616.25976562])"
|
||||
]
|
||||
},
|
||||
"execution_count": 34,
|
||||
"execution_count": 27,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -2049,18 +2049,6 @@
|
||||
"display_name": "Python 2",
|
||||
"language": "python",
|
||||
"name": "python2"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 2
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython2",
|
||||
"version": "2.7.9"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,790 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {
|
||||
"collapsed": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import SimPEG as simpeg\n",
|
||||
"import simpegMT as simpegmt\n",
|
||||
"import numpy as np"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"## Setup the problem\n",
|
||||
"\n",
|
||||
"# Frequency\n",
|
||||
"nFreq = 33\n",
|
||||
"freqs = np.logspace(3,-3,nFreq)\n",
|
||||
"# freqs = np.array([100,10,1,0.1,0.01])\n",
|
||||
"# Make the mesh\n",
|
||||
"ct = 10\n",
|
||||
"air = simpeg.Utils.meshTensor([(ct,15,1.3)])\n",
|
||||
"core = np.concatenate( ( np.kron(simpeg.Utils.meshTensor([(ct,15,-1.2)]),np.ones((5,))) , simpeg.Utils.meshTensor([(ct,5)]) ) )\n",
|
||||
"bot = simpeg.Utils.meshTensor([(core[0],10,-1.3)])\n",
|
||||
"x0 = -np.array([np.sum(np.concatenate((core,bot)))])\n",
|
||||
"# Change to use no air\n",
|
||||
"m1d = simpeg.Mesh.TensorMesh([np.concatenate((bot,core,air))], x0=x0)\n",
|
||||
"\n",
|
||||
"## Setup model varibles\n",
|
||||
"active = m1d.vectorCCx<0.\n",
|
||||
"layer1 = (m1d.vectorCCx<-200.) & (m1d.vectorCCx>=-600.)\n",
|
||||
"layer2 = (m1d.vectorCCx<-2000.) & (m1d.vectorCCx>=-4000.)\n",
|
||||
"actMap = simpeg.Maps.ActiveCells(m1d, active, np.log(1e-8), nC=m1d.nCx)\n",
|
||||
"mappingExpAct = simpeg.Maps.ExpMap(m1d) * actMap\n",
|
||||
"sig_half = 2e-3\n",
|
||||
"sig_air = 1e-8\n",
|
||||
"sig_layer1 = 1\n",
|
||||
"sig_layer2 = .1\n",
|
||||
"# Make the true model\n",
|
||||
"sigma_true = np.ones(m1d.nCx)*sig_air\n",
|
||||
"sigma_true[active] = sig_half\n",
|
||||
"sigma_true[layer1] = sig_layer1\n",
|
||||
"sigma_true[layer2] = sig_layer2\n",
|
||||
"m_true = np.log(sigma_true[active])\n",
|
||||
"# Make the background model\n",
|
||||
"sigma_0 = np.ones(m1d.nCx)*sig_air\n",
|
||||
"sigma_0[active] = sig_half\n",
|
||||
"m_0 = np.log(sigma_0[active])\n",
|
||||
"\n",
|
||||
"# Receivers \n",
|
||||
"# 1D impedance at the surface (elevation 0)\n",
|
||||
"rxList = []\n",
|
||||
"for rxType in ['z1dr','z1di']:\n",
|
||||
" rxList.append(simpegmt.SurveyMT.RxMT(simpeg.mkvc(np.array([0.0]),2).T,rxType))\n",
|
||||
"# Source list\n",
|
||||
"srcList =[]\n",
|
||||
"tD = False\n",
|
||||
"if tD:\n",
|
||||
" for freq in freqs:\n",
|
||||
" srcList.append(simpegmt.SurveyMT.srcMT_polxy_1DhomotD(rxList,freq))\n",
|
||||
"else:\n",
|
||||
" for freq in freqs:\n",
|
||||
" srcList.append(simpegmt.SurveyMT.srcMT_polxy_1Dprimary(rxList,freq,sigma_0))\n",
|
||||
"# Make the survey\n",
|
||||
"survey = simpegmt.SurveyMT.SurveyMT(srcList)\n",
|
||||
"survey.mtrue = m_true\n",
|
||||
"# Set the problem\n",
|
||||
"problem = simpegmt.ProblemMT1D.eForm_psField(m1d,mapping=mappingExpAct)\n",
|
||||
"from pymatsolver import MumpsSolver\n",
|
||||
"problem.solver = MumpsSolver\n",
|
||||
"problem.pair(survey)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 28,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"105"
|
||||
]
|
||||
},
|
||||
"execution_count": 28,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"m1d.nC"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"0.002"
|
||||
]
|
||||
},
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"sig_half"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"## Make the observed data \n",
|
||||
"# Project the data\n",
|
||||
"d_true = survey.dpred(m_true)\n",
|
||||
"survey.dtrue = d_true\n",
|
||||
"# Add noise\n",
|
||||
"std = 0.05 # 5% std\n",
|
||||
"noise = std*abs(survey.dtrue)*np.random.randn(*survey.dtrue.shape)\n",
|
||||
"# Assign the dobs\n",
|
||||
"survey.dobs = survey.dtrue + noise\n",
|
||||
"survey.std = survey.dobs*0 + std\n",
|
||||
"# Assign the data weight\n",
|
||||
"survey.Wd = 1/(abs(survey.dobs)*std)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"## Setup the inversion proceedure\n",
|
||||
"C = simpeg.Utils.Counter()\n",
|
||||
"\n",
|
||||
"# Set the optimization\n",
|
||||
"opt = simpeg.Optimization.InexactGaussNewton(maxIter = 30)\n",
|
||||
"opt.counter = C\n",
|
||||
"opt.LSshorten = 0.5\n",
|
||||
"opt.remember('xc')\n",
|
||||
"# Data misfit\n",
|
||||
"dmis = simpeg.DataMisfit.l2_DataMisfit(survey)\n",
|
||||
"# Regularization\n",
|
||||
"# regMesh = simpeg.Mesh.TensorMesh([m1d.hx[problem.mapping.sigmaMap.maps[-1].indActive]])\n",
|
||||
"# reg = simpeg.Regularization.Tikhonov(regMesh)\n",
|
||||
"reg = simpeg.Regularization.Tikhonov(m1d,mapping=mappingExpAct)\n",
|
||||
"reg.alpha_s = 1e-5\n",
|
||||
"reg.alpha_x = 1.\n",
|
||||
"\n",
|
||||
"# Inversion problem\n",
|
||||
"invProb = simpeg.InvProblem.BaseInvProblem(dmis, reg, opt)\n",
|
||||
"invProb.counter = C\n",
|
||||
"# Beta cooling\n",
|
||||
"beta = simpeg.Directives.BetaSchedule()\n",
|
||||
"betaest = simpeg.Directives.BetaEstimate_ByEig(beta0_ratio=0.75)\n",
|
||||
"saveModel = simpeg.Directives.SaveModelEveryIteration()\n",
|
||||
"# Create an inversion object\n",
|
||||
"inv = simpeg.Inversion.BaseInversion(invProb, directiveList=[beta,betaest])#,saveModel]) \n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"<SimPEG.Maps.ActiveCells at 0x7fcfc8df5650>"
|
||||
]
|
||||
},
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"problem.mapping.sigmaMap.maps[-1]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"SimPEG.InvProblem will set Regularization.mref to m0.\n",
|
||||
"SimPEG.InvProblem is setting bfgsH0 to the inverse of the eval2Deriv.\n",
|
||||
" ***Done using same solver as the problem***\n",
|
||||
"SimPEG.l2_DataMisfit is creating default weightings for Wd.\n",
|
||||
"============================ Inexact Gauss Newton ============================\n",
|
||||
" # beta phi_d phi_m f |proj(x-g)-x| LS Comment \n",
|
||||
"-----------------------------------------------------------------------------\n",
|
||||
" 0 4.83e+05 1.46e+06 6.90e-07 1.46e+06 2.09e+05 0 \n",
|
||||
" 1 4.83e+05 1.80e+05 5.76e-06 1.80e+05 2.64e+04 0 \n",
|
||||
" 2 4.83e+05 1.29e+05 7.58e-06 1.29e+05 2.05e+04 0 Skip BFGS \n",
|
||||
" 3 6.04e+04 1.10e+05 8.89e-06 1.10e+05 1.82e+04 0 Skip BFGS \n",
|
||||
" 4 6.04e+04 5.48e+04 1.97e-05 5.48e+04 1.05e+04 0 Skip BFGS \n",
|
||||
" 5 6.04e+04 4.57e+04 2.46e-05 4.57e+04 9.11e+03 0 Skip BFGS \n",
|
||||
" 6 7.55e+03 4.04e+04 2.88e-05 4.04e+04 8.25e+03 0 Skip BFGS \n",
|
||||
" 7 7.55e+03 2.22e+04 6.11e-05 2.22e+04 5.14e+03 0 Skip BFGS \n",
|
||||
" 8 7.55e+03 1.81e+04 7.86e-05 1.81e+04 4.38e+03 0 Skip BFGS \n",
|
||||
" 9 9.44e+02 1.58e+04 9.29e-05 1.58e+04 3.94e+03 0 Skip BFGS \n",
|
||||
" 10 9.44e+02 8.37e+03 1.97e-04 8.37e+03 2.43e+03 0 Skip BFGS \n",
|
||||
" 11 9.44e+02 6.71e+03 2.54e-04 6.71e+03 2.05e+03 0 Skip BFGS \n",
|
||||
" 12 1.18e+02 5.78e+03 3.01e-04 5.78e+03 1.83e+03 0 Skip BFGS \n",
|
||||
" 13 1.18e+02 3.04e+03 6.06e-04 3.04e+03 1.11e+03 0 Skip BFGS \n",
|
||||
" 14 1.18e+02 2.42e+03 7.75e-04 2.42e+03 9.25e+02 0 Skip BFGS \n",
|
||||
" 15 1.47e+01 2.09e+03 9.10e-04 2.09e+03 8.15e+02 0 Skip BFGS \n",
|
||||
" 16 1.47e+01 1.21e+03 1.66e-03 1.21e+03 4.81e+02 0 Skip BFGS \n",
|
||||
" 17 1.47e+01 9.97e+02 2.07e-03 9.97e+02 3.82e+02 0 Skip BFGS \n",
|
||||
" 18 1.84e+00 8.79e+02 2.36e-03 8.79e+02 3.30e+02 0 Skip BFGS \n",
|
||||
" 19 1.84e+00 6.16e+02 3.62e-03 6.16e+02 1.99e+02 0 Skip BFGS \n",
|
||||
" 20 1.84e+00 5.31e+02 4.24e-03 5.31e+02 1.64e+02 0 Skip BFGS \n",
|
||||
" 21 2.30e-01 4.79e+02 4.68e-03 4.79e+02 1.45e+02 0 Skip BFGS \n",
|
||||
" 22 2.30e-01 3.38e+02 6.36e-03 3.38e+02 1.01e+02 0 Skip BFGS \n",
|
||||
" 23 2.30e-01 2.80e+02 7.02e-03 2.80e+02 8.93e+01 0 Skip BFGS \n",
|
||||
" 24 2.88e-02 2.32e+02 7.55e-03 2.32e+02 8.14e+01 0 Skip BFGS \n",
|
||||
" 25 2.88e-02 1.53e+02 1.08e-02 1.53e+02 6.94e+01 0 Skip BFGS \n",
|
||||
" 26 2.88e-02 8.67e+01 1.27e-02 8.67e+01 3.84e+01 0 \n",
|
||||
" 27 3.60e-03 6.54e+01 1.40e-02 6.54e+01 3.13e+01 0 Skip BFGS \n",
|
||||
" 28 3.60e-03 3.48e+01 1.69e-02 3.48e+01 2.06e+01 0 Skip BFGS \n",
|
||||
" 29 3.60e-03 2.63e+01 1.86e-02 2.63e+01 1.07e+01 0 Skip BFGS \n",
|
||||
" 30 4.50e-04 2.19e+01 2.17e-02 2.19e+01 7.17e+00 0 Skip BFGS \n",
|
||||
"------------------------- STOP! -------------------------\n",
|
||||
"1 : |fc-fOld| = 4.3709e+00 <= tolF*(1+|f0|) = 1.4560e+05\n",
|
||||
"1 : |xc-x_last| = 2.1874e+00 <= tolX*(1+|x0|) = 5.9957e+00\n",
|
||||
"0 : |proj(x-g)-x| = 7.1673e+00 <= tolG = 1.0000e-01\n",
|
||||
"0 : |proj(x-g)-x| = 7.1673e+00 <= 1e3*eps = 1.0000e-02\n",
|
||||
"1 : maxIter = 30 <= iter = 30\n",
|
||||
"------------------------- DONE! -------------------------\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Runn the inversion\n",
|
||||
"mopt = inv.run(m_0)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 18,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"[{'left': <function SimPEG.Optimization.<lambda>>,\n",
|
||||
" 'right': <function SimPEG.Optimization.<lambda>>,\n",
|
||||
" 'stopType': 'critical',\n",
|
||||
" 'str': '%d : maxIter = %3d <= iter = %3d'}]"
|
||||
]
|
||||
},
|
||||
"execution_count": 18,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"## Setup the inversion proceedure\n",
|
||||
"C = simpeg.Utils.Counter()\n",
|
||||
"\n",
|
||||
"# Set the optimization\n",
|
||||
"optc = simpeg.Optimization.InexactGaussNewton(maxIter = 20)\n",
|
||||
"optc.counter = C\n",
|
||||
"optc.LSshorten = 0.5\n",
|
||||
"optc.remember('xc')\n",
|
||||
"# Data misfit\n",
|
||||
"dmisc = simpeg.DataMisfit.l2_DataMisfit(survey)\n",
|
||||
"# Regularization\n",
|
||||
"# regMesh = simpeg.Mesh.TensorMesh([m1d.hx[problem.mapping.sigmaMap.maps[-1].indActive]])\n",
|
||||
"# reg = simpeg.Regularization.Tikhonov(regMesh)\n",
|
||||
"regc = simpeg.Regularization.Tikhonov(m1d,mapping=mappingExpAct)\n",
|
||||
"regc.alpha_s = 1e-5\n",
|
||||
"regc.alpha_x = 1.\n",
|
||||
"# Inversion problem\n",
|
||||
"invProbc = simpeg.InvProblem.BaseInvProblem(dmisc, regc, optc)\n",
|
||||
"invProbc.counter = C\n",
|
||||
"# Beta cooling\n",
|
||||
"betac = simpeg.Directives.BetaSchedule()\n",
|
||||
"betaestc = simpeg.Directives.BetaEstimate_ByEig(beta0_ratio=0.75)\n",
|
||||
"saveModel = simpeg.Directives.SaveModelEveryIteration()\n",
|
||||
"# Create an inversion object\n",
|
||||
"invc = simpeg.Inversion.BaseInversion(invProbc, directiveList=[betac,betaestc])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"SimPEG.InvProblem will set Regularization.mref to m0.\n",
|
||||
"SimPEG.InvProblem is setting bfgsH0 to the inverse of the eval2Deriv.\n",
|
||||
" ***Done using same solver as the problem***\n",
|
||||
"SimPEG.l2_DataMisfit is creating default weightings for Wd.\n",
|
||||
"============================ Inexact Gauss Newton ============================\n",
|
||||
" # beta phi_d phi_m f |proj(x-g)-x| LS Comment \n",
|
||||
"-----------------------------------------------------------------------------\n",
|
||||
" 0 9.87e+02 2.19e+01 2.35e-02 4.51e+01 3.23e+01 0 \n",
|
||||
" 1 9.87e+02 2.38e+01 1.74e-02 4.09e+01 7.61e+00 0 \n",
|
||||
" 2 9.87e+02 2.30e+01 1.79e-02 4.06e+01 2.68e+00 0 \n",
|
||||
" 3 1.23e+02 2.28e+01 1.79e-02 2.50e+01 1.54e+01 0 \n",
|
||||
" 4 1.23e+02 2.07e+01 2.24e-02 2.35e+01 5.36e+00 0 \n",
|
||||
" 5 1.23e+02 2.03e+01 2.22e-02 2.30e+01 6.78e+00 0 Skip BFGS \n",
|
||||
" 6 1.54e+01 2.00e+01 2.33e-02 2.03e+01 7.34e+00 0 Skip BFGS \n",
|
||||
" 7 1.54e+01 1.95e+01 3.01e-02 2.00e+01 7.09e+00 0 \n",
|
||||
" 8 1.54e+01 1.92e+01 3.30e-02 1.97e+01 5.00e+00 0 \n",
|
||||
" 9 1.93e+00 1.91e+01 3.72e-02 1.91e+01 5.68e+00 0 \n",
|
||||
" 10 1.93e+00 1.88e+01 6.62e-02 1.89e+01 8.43e+00 1 \n",
|
||||
" 11 1.93e+00 1.82e+01 1.12e-01 1.84e+01 5.37e+00 0 \n",
|
||||
" 12 2.41e-01 1.81e+01 1.21e-01 1.81e+01 5.14e+00 0 \n",
|
||||
" 13 2.41e-01 1.80e+01 1.18e-01 1.80e+01 3.93e+00 0 \n",
|
||||
" 14 2.41e-01 1.80e+01 1.43e-01 1.80e+01 6.08e+00 0 \n",
|
||||
" 15 3.01e-02 1.78e+01 1.19e-01 1.78e+01 4.97e+00 1 \n",
|
||||
" 16 3.01e-02 1.78e+01 1.13e-01 1.78e+01 2.41e+00 0 Skip BFGS \n",
|
||||
" 17 3.01e-02 1.78e+01 1.37e-01 1.78e+01 4.47e+00 0 \n",
|
||||
" 18 3.77e-03 1.76e+01 1.28e-01 1.76e+01 6.24e+00 0 Skip BFGS \n",
|
||||
" 19 3.77e-03 1.76e+01 1.07e-01 1.76e+01 7.34e+00 0 \n",
|
||||
" 20 3.77e-03 1.75e+01 1.25e-01 1.75e+01 6.14e+00 1 \n",
|
||||
"------------------------- STOP! -------------------------\n",
|
||||
"1 : |fc-fOld| = 4.7935e-02 <= tolF*(1+|f0|) = 4.6080e+00\n",
|
||||
"1 : |xc-x_last| = 3.4384e+00 <= tolX*(1+|x0|) = 4.0560e+00\n",
|
||||
"0 : |proj(x-g)-x| = 6.1413e+00 <= tolG = 1.0000e-01\n",
|
||||
"0 : |proj(x-g)-x| = 6.1413e+00 <= 1e3*eps = 1.0000e-02\n",
|
||||
"1 : maxIter = 20 <= iter = 20\n",
|
||||
"------------------------- DONE! -------------------------\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"mopt2 = invc.run(mopt)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 24,
|
||||
"metadata": {
|
||||
"collapsed": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"moptc=mopt2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 26,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"## Setup the inversion proceedure\n",
|
||||
"C = simpeg.Utils.Counter()\n",
|
||||
"\n",
|
||||
"# Set the optimization\n",
|
||||
"optc1 = simpeg.Optimization.InexactGaussNewton(maxIter = 20)\n",
|
||||
"optc1.counter = C\n",
|
||||
"optc1.LSshorten = 0.1\n",
|
||||
"optc1.remember('xc')\n",
|
||||
"# Data misfit\n",
|
||||
"dmisc1 = simpeg.DataMisfit.l2_DataMisfit(survey)\n",
|
||||
"# Regularization\n",
|
||||
"# regMesh = simpeg.Mesh.TensorMesh([m1d.hx[problem.mapping.sigmaMap.maps[-1].indActive]])\n",
|
||||
"# reg = simpeg.Regularization.Tikhonov(regMesh)\n",
|
||||
"regc1 = simpeg.Regularization.Tikhonov(m1d,mapping=mappingExpAct)\n",
|
||||
"regc1.alpha_s = 1e-5\n",
|
||||
"regc1.alpha_x = 1.\n",
|
||||
"regc1.mref = reg.mref\n",
|
||||
"# Inversion problem\n",
|
||||
"invProbc1 = simpeg.InvProblem.BaseInvProblem(dmisc1, regc1, optc1)\n",
|
||||
"invProbc1.counter = C\n",
|
||||
"# Beta cooling\n",
|
||||
"betac1 = simpeg.Directives.BetaSchedule()\n",
|
||||
"betaestc1 = simpeg.Directives.BetaEstimate_ByEig(beta0_ratio=0.75)\n",
|
||||
"betaestc1.beta0 = 3.60e-03\n",
|
||||
"saveModel = simpeg.Directives.SaveModelEveryIteration()\n",
|
||||
"# Create an inversion object\n",
|
||||
"invc1 = simpeg.Inversion.BaseInversion(invProbc1, directiveList=[betac1,betaestc1])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 27,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"SimPEG.InvProblem is setting bfgsH0 to the inverse of the eval2Deriv.\n",
|
||||
" ***Done using same solver as the problem***\n",
|
||||
"SimPEG.l2_DataMisfit is creating default weightings for Wd.\n",
|
||||
"============================ Inexact Gauss Newton ============================\n",
|
||||
" # beta phi_d phi_m f |proj(x-g)-x| LS Comment \n",
|
||||
"-----------------------------------------------------------------------------\n",
|
||||
" 0 1.79e-02 1.75e+01 1.23e-01 1.75e+01 6.14e+00 0 \n",
|
||||
" 1 1.79e-02 1.75e+01 1.23e-01 1.75e+01 6.14e+00 3 \n",
|
||||
" 2 1.79e-02 1.75e+01 1.23e-01 1.75e+01 6.15e+00 3 Skip BFGS \n",
|
||||
" 3 2.23e-03 1.75e+01 1.23e-01 1.75e+01 6.16e+00 3 Skip BFGS \n",
|
||||
" 4 2.23e-03 1.75e+01 1.23e-01 1.75e+01 6.17e+00 3 Skip BFGS \n",
|
||||
" 5 2.23e-03 1.75e+01 1.23e-01 1.75e+01 6.17e+00 3 Skip BFGS \n",
|
||||
" 6 2.79e-04 1.75e+01 1.23e-01 1.75e+01 6.17e+00 3 Skip BFGS \n",
|
||||
" 7 2.79e-04 1.75e+01 1.23e-01 1.75e+01 6.17e+00 3 Skip BFGS \n",
|
||||
" 8 2.79e-04 1.75e+01 1.23e-01 1.75e+01 6.17e+00 3 Skip BFGS \n",
|
||||
" 9 3.49e-05 1.75e+01 1.23e-01 1.75e+01 6.17e+00 3 Skip BFGS \n",
|
||||
" 10 3.49e-05 1.75e+01 1.23e-01 1.75e+01 6.17e+00 3 Skip BFGS \n",
|
||||
" 11 3.49e-05 1.75e+01 1.23e-01 1.75e+01 6.17e+00 3 Skip BFGS \n",
|
||||
" 12 4.36e-06 1.75e+01 1.23e-01 1.75e+01 6.16e+00 3 Skip BFGS \n",
|
||||
" 13 4.36e-06 1.75e+01 1.23e-01 1.75e+01 6.16e+00 3 Skip BFGS \n",
|
||||
" 14 4.36e-06 1.75e+01 1.23e-01 1.75e+01 6.29e+00 2 Skip BFGS \n",
|
||||
" 15 5.46e-07 1.75e+01 1.23e-01 1.75e+01 6.32e+00 2 Skip BFGS \n",
|
||||
" 16 5.46e-07 1.75e+01 1.23e-01 1.75e+01 6.31e+00 2 Skip BFGS \n",
|
||||
" 17 5.46e-07 1.75e+01 1.23e-01 1.75e+01 6.29e+00 2 Skip BFGS \n",
|
||||
" 18 6.82e-08 1.75e+01 1.23e-01 1.75e+01 6.26e+00 2 Skip BFGS \n",
|
||||
" 19 6.82e-08 1.75e+01 1.23e-01 1.75e+01 6.22e+00 2 Skip BFGS \n",
|
||||
" 20 6.82e-08 1.75e+01 1.23e-01 1.75e+01 6.18e+00 2 Skip BFGS \n",
|
||||
"------------------------- STOP! -------------------------\n",
|
||||
"1 : |fc-fOld| = 3.9817e-03 <= tolF*(1+|f0|) = 1.8547e+00\n",
|
||||
"0 : |xc-x_last| = 4.1858e+01 <= tolX*(1+|x0|) = 5.7798e+00\n",
|
||||
"0 : |proj(x-g)-x| = 6.1825e+00 <= tolG = 1.0000e-01\n",
|
||||
"0 : |proj(x-g)-x| = 6.1825e+00 <= 1e3*eps = 1.0000e-02\n",
|
||||
"1 : maxIter = 20 <= iter = 20\n",
|
||||
"------------------------- DONE! -------------------------\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"moptc1 = invc1.run(mopt2)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Counters:\n",
|
||||
" InexactGaussNewton.doEndIteration : 30\n",
|
||||
" InexactGaussNewton.doStartIteration : 31\n",
|
||||
" InexactGaussNewton.scaleSearchDirection : 30\n",
|
||||
"\n",
|
||||
"Times: mean sum\n",
|
||||
" BaseInvProblem.evalFunction : 3.35e+00, 2.04e+02, 61x\n",
|
||||
" InexactGaussNewton.findSearchDirection : 2.11e+01, 6.34e+02, 30x\n",
|
||||
" InexactGaussNewton.minimize : 8.39e+02, 8.39e+02, 1x\n",
|
||||
" InexactGaussNewton.modifySearchDirection: 1.90e+00, 5.71e+01, 30x\n",
|
||||
" InexactGaussNewton.projection : 4.65e-05, 5.86e-03, 126x\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"opt.counter.summary()\n",
|
||||
"xc = opt.recall('xc')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# import matplotlib.pyplot as plt\n",
|
||||
"# # plt.figure(1)\n",
|
||||
"# # for i in range(problem.G.shape[0]):\n",
|
||||
"# # plt.plot(problem.G[i,:])\n",
|
||||
"# meshPts = np.concatenate((mesh.gridN[0:1],np.kron(mesh.gridN[1::],np.ones(2))[:-1]))\n",
|
||||
"# modelPts = np.kron(1./model,np.ones(2,))\n",
|
||||
"# axM.semilogx(modelPts,meshPts,color=col)\n",
|
||||
"# plt.figure(2)\n",
|
||||
"# plt.plot(m1d.vectorCCx[active], np.log10(mappingExpAct*survey.mtrue)[active], 'b-')\n",
|
||||
"# plt.plot(m1d.vectorCCx[active], np.log10(mappingExpAct*mopt)[active], 'r-')\n",
|
||||
"# plt.show()\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def plotMT1DModelData(problem,models,symList=None):\n",
|
||||
" # Make the analytic solution\n",
|
||||
" # \tdef makeAnalyticSolution(mesh,model,elev,freqs):\n",
|
||||
" # \t\tdata1D = []\n",
|
||||
" # \t\tfor freq in freqs:\n",
|
||||
" # \t\t\tanaEd, anaEu, anaHd, anaHu = simpegmt.Utils.MT1Danalytic.getEHfields(mesh,model,freq,elev)\n",
|
||||
" # \t\t\tanaE = anaEd+anaEu\n",
|
||||
" # \t\t\tanaH = anaHd+anaHu\n",
|
||||
" # \t\t\t# Scale the solution\n",
|
||||
" # \t\t\t# anaE = (anaEtemp/anaEtemp[-1])#.conj()\n",
|
||||
" # \t\t\t# anaH = (anaHtemp/anaEtemp[-1])#.conj()\n",
|
||||
" # \t\t\tanaZ = anaE/anaH\n",
|
||||
" # \t\t\t# Add to the list\n",
|
||||
" # \t\t\tdata1D.append((freq,0,0,elev,anaZ[0]))\n",
|
||||
" # \t\tdataRec = np.array(data1D,dtype=[('freq',float),('x',float),('y',float),('z',float),('zxx',complex)])\n",
|
||||
" # \t\treturn dataRec\n",
|
||||
" def appResPhs(freq,z):\n",
|
||||
" fr = simpeg.mkvc(freq,2)*np.ones(z.shape)\n",
|
||||
" app_res = ((1./(8e-7*np.pi**2))/fr)*np.abs(z)**2\n",
|
||||
" app_phs = np.arctan2(z.imag,z.real)*(180/np.pi)\n",
|
||||
" return app_res, app_phs\n",
|
||||
" \n",
|
||||
" # Setup the figure\n",
|
||||
" fontSize = 15\n",
|
||||
"\n",
|
||||
" fig = plt.figure(figsize=[9,7])\n",
|
||||
" axM = fig.add_axes([0.075,.1,.25,.875])\n",
|
||||
" axM.set_xlabel('Resistivity [Ohm*m]',fontsize=fontSize)\n",
|
||||
" axM.set_xlim(1e-1,1e5)\n",
|
||||
" axM.set_ylim(-10000,5000)\n",
|
||||
" axM.set_ylabel('Depth [km]',fontsize=fontSize)\n",
|
||||
" axR = fig.add_axes([0.42,.575,.5,.4])\n",
|
||||
" axR.set_xscale('log')\n",
|
||||
" axR.set_yscale('log')\n",
|
||||
" axR.invert_xaxis()\n",
|
||||
" # axR.set_xlabel('Frequency [Hz]')\n",
|
||||
" axR.set_ylabel('Apparent resistivity [Ohm m]',fontsize=fontSize)\n",
|
||||
"\n",
|
||||
" axP = fig.add_axes([0.42,.1,.5,.4])\n",
|
||||
" axP.set_xscale('log')\n",
|
||||
" axP.invert_xaxis()\n",
|
||||
" axP.set_ylim(0,90)\n",
|
||||
" axP.set_xlabel('Frequency [Hz]',fontsize=fontSize)\n",
|
||||
" axP.set_ylabel('Apparent phase [deg]',fontsize=fontSize)\n",
|
||||
"\n",
|
||||
" # if not symList:\n",
|
||||
" # \tsymList = ['x']*len(models)\n",
|
||||
" sys.path.append('/home/gudni/Dropbox/code/python/MTview')\n",
|
||||
" import plotDataTypes as pDt\n",
|
||||
" # Loop through the models.\n",
|
||||
" modelList = [problem.survey.mtrue]\n",
|
||||
" modelList.extend(models)\n",
|
||||
" if False:\n",
|
||||
" modelList = [problem.mapping.sigmaMap*mod for mod in modelList]\n",
|
||||
" for nr, model in enumerate(modelList):\n",
|
||||
" # Calculate the data\n",
|
||||
" if nr==0:\n",
|
||||
" data1D = problem.dataPair(problem.survey,problem.survey.dobs).toRecArray('Complex')\n",
|
||||
" else:\n",
|
||||
" data1D = problem.dataPair(problem.survey,problem.survey.dpred(model)).toRecArray('Complex')\n",
|
||||
" # Plot the data and the model \n",
|
||||
" colRat = nr/((len(modelList)-2)*1.)\n",
|
||||
" if colRat > 1.:\n",
|
||||
" col = 'k'\n",
|
||||
" else:\n",
|
||||
" col = plt.cm.seismic(1-colRat)\n",
|
||||
" # The model - make the pts to plot\n",
|
||||
" meshPts = np.concatenate((problem.mesh.gridN[0:1],np.kron(problem.mesh.gridN[1::],np.ones(2))[:-1]))\n",
|
||||
" modelPts = np.kron(1./(problem.mapping.sigmaMap*model),np.ones(2,))\n",
|
||||
" axM.semilogx(modelPts,meshPts,color=col)\n",
|
||||
"\n",
|
||||
" ## Data\n",
|
||||
" # Appres\n",
|
||||
" pDt.plotIsoStaImpedance(axR,np.array([0,0]),data1D,'zyx','res',pColor=col)\n",
|
||||
" # Appphs\n",
|
||||
" pDt.plotIsoStaImpedance(axP,np.array([0,0]),data1D,'zyx','phs',pColor=col)\n",
|
||||
" try:\n",
|
||||
" allData = np.concatenate((allData,mkvc(data1D['zyx'],2)),1)\n",
|
||||
" except:\n",
|
||||
" allData = simpeg.mkvc(data1D['zyx'],2)\n",
|
||||
" freq = data1D['freq']\n",
|
||||
" res, phs = appResPhs(freq,allData)\n",
|
||||
"\n",
|
||||
" stdCol = 'gray'\n",
|
||||
" axRtw = axR.twinx()\n",
|
||||
" axRtw.set_ylabel('Std of log10',color=stdCol)\n",
|
||||
" [(t.set_color(stdCol), t.set_rotation(-45)) for t in axRtw.get_yticklabels()]\n",
|
||||
" axPtw = axP.twinx()\n",
|
||||
" axPtw.set_ylabel('Std ',color=stdCol)\n",
|
||||
" [t.set_color(stdCol) for t in axPtw.get_yticklabels()]\n",
|
||||
" axRtw.plot(freq, np.std(np.log10(res),1),'--',color=stdCol)\n",
|
||||
" axPtw.plot(freq, np.std(phs,1),'--',color=stdCol)\n",
|
||||
"\n",
|
||||
" # Fix labels and ticks\n",
|
||||
"\n",
|
||||
" yMtick = [l/1000 for l in axM.get_yticks().tolist()]\n",
|
||||
" axM.set_yticklabels(yMtick)\n",
|
||||
" [ l.set_rotation(90) for l in axM.get_yticklabels()]\n",
|
||||
" [ l.set_rotation(90) for l in axR.get_yticklabels()]\n",
|
||||
" [(t.set_color(stdCol), t.set_rotation(-45)) for t in axRtw.get_yticklabels()]\n",
|
||||
" [t.set_color(stdCol) for t in axPtw.get_yticklabels()]\n",
|
||||
" for ax in [axM,axR,axP]:\n",
|
||||
" ax.xaxis.set_tick_params(labelsize=fontSize)\n",
|
||||
" ax.yaxis.set_tick_params(labelsize=fontSize)\n",
|
||||
" return fig\n",
|
||||
"# plotMT1DModelData(problem,[mopt])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 14,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"/home/gudni/anaconda/lib/python2.7/site-packages/numpy/ma/core.py:2834: FutureWarning: Numpy has detected that you (may be) writing to an array returned\n",
|
||||
"by numpy.diagonal or by selecting multiple fields in a record\n",
|
||||
"array. This code will likely break in a future numpy release --\n",
|
||||
"see numpy.diagonal or arrays.indexing reference docs for details.\n",
|
||||
"The quick fix is to make an explicit copy (e.g., do\n",
|
||||
"arr.diagonal().copy() or arr[['f0','f1']].copy()).\n",
|
||||
" if (obj.__array_interface__[\"data\"][0]\n",
|
||||
"/home/gudni/anaconda/lib/python2.7/site-packages/numpy/ma/core.py:2835: FutureWarning: Numpy has detected that you (may be) writing to an array returned\n",
|
||||
"by numpy.diagonal or by selecting multiple fields in a record\n",
|
||||
"array. This code will likely break in a future numpy release --\n",
|
||||
"see numpy.diagonal or arrays.indexing reference docs for details.\n",
|
||||
"The quick fix is to make an explicit copy (e.g., do\n",
|
||||
"arr.diagonal().copy() or arr[['f0','f1']].copy()).\n",
|
||||
" != self.__array_interface__[\"data\"][0]):\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"plotMT1DModelData(problem,[mopt,mopt2])\n",
|
||||
"plt.show()\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 15,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"modelList = [problem.survey.mtrue]\n",
|
||||
"modelList.extend([mopt])\n",
|
||||
"# problem.mapping.sigmaMap*mopt"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 16,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"[['zyxr'], ['zyxi']]"
|
||||
]
|
||||
},
|
||||
"execution_count": 16,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"src = survey.srcList[0]\n",
|
||||
"[[rx.rxType.replace('z1d','zyx')] for rx in src.rxList ]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 17,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"'zyxr'"
|
||||
]
|
||||
},
|
||||
"execution_count": 17,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"'z1dr'.replace('z1d','zyx')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 2",
|
||||
"language": "python",
|
||||
"name": "python2"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 2
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython2",
|
||||
"version": "2.7.9"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
}
|
||||
@@ -0,0 +1,938 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import SimPEG as simpeg\n",
|
||||
"import simpegEM as simpegem, simpegMT as simpegmt\n",
|
||||
"from SimPEG.Utils import meshTensor\n",
|
||||
"import numpy as np\n",
|
||||
"import simpegMT.Tests.test_Problem3D_againstAnalytic as t3Dmt"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"collapsed": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"sigmaHalf = 0.01\n",
|
||||
"survey, problem = t3Dmt.setupSimpegMTfwd_eForm_ps(t3Dmt.halfSpace(sigmaHalf),comp='zxyi',singleFreq=1)\n",
|
||||
"if False:\n",
|
||||
" fields = problem.fields(problem.curModel.sigma)\n",
|
||||
" data = survey.dpred(problem.curModel.sigma)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"==================== checkDerivative ====================\n",
|
||||
"iter h |ft-f0| |ft-f0-h*J0*dx| Order\n",
|
||||
"---------------------------------------------------------\n",
|
||||
" 0 1.00e-01 3.111e+11 3.481e+10 nan\n",
|
||||
" 1 1.00e-02 3.112e+10 3.421e+08 2.008\n",
|
||||
" 2 1.00e-03 3.116e+09 3.420e+06 2.000\n",
|
||||
"========================= PASS! =========================\n",
|
||||
"Once upon a time, a happy little test passed.\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"True"
|
||||
]
|
||||
},
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"def testDeriv_dA_dm(prb,cond):\n",
|
||||
" TOL = 1e-4\n",
|
||||
" FLR = 1e-20\n",
|
||||
" x0 = np.log(np.ones(prb.mesh.nC)*cond)\n",
|
||||
" prb.mapping = simpeg.Maps.ExpMap(prb.mesh)\n",
|
||||
" if True:\n",
|
||||
" x0 = x0 + np.random.randn(prb.mesh.nC)*cond*1e-1 \n",
|
||||
" survey = prb.survey\n",
|
||||
" src = survey.srcList[0]\n",
|
||||
" freq = src.freq\n",
|
||||
" v1 = np.random.randn(prb.mesh.nE,1)\n",
|
||||
" v2 = np.random.randn(prb.mesh.nE,1)\n",
|
||||
" v = np.hstack(( simpeg.mkvc(v1,2), simpeg.mkvc(v2,2)))\n",
|
||||
" u_0 = prb.fieldsPair(prb.mesh,prb.survey)\n",
|
||||
" u_0[src,'e_pxSolution'] = v1\n",
|
||||
" u_0[src,'e_pySolution'] = v2\n",
|
||||
" def fun(x):\n",
|
||||
" prb.curModel = x\n",
|
||||
" A = prb.getA(freq) #\n",
|
||||
"# return simpeg.mkvc(A*v1)+simpeg.mkvc(A*v2), lambda t: simpeg.mkvc(prb.getADeriv_m(freq, u_0[src], t))\n",
|
||||
" return A*v, lambda t: (prb.getADeriv_m(freq, u_0[src], t))\n",
|
||||
" return simpeg.Tests.checkDerivative(fun, x0, num=3, plotIt=False, eps=FLR)\n",
|
||||
"testDeriv_dA_dm(problem,0.1)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"==================== checkDerivative ====================\n",
|
||||
"iter h |ft-f0| |ft-f0-h*J0*dx| Order\n",
|
||||
"---------------------------------------------------------\n",
|
||||
" 0 1.00e-01 3.187e+11 3.398e+10 nan\n",
|
||||
" 1 1.00e-02 3.176e+10 3.369e+08 2.004\n",
|
||||
" 2 1.00e-03 3.178e+09 3.372e+06 2.000\n",
|
||||
"========================= PASS! =========================\n",
|
||||
"That was easy!\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"True"
|
||||
]
|
||||
},
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"def testDeriv_dRHS_dm(prb,cond):\n",
|
||||
" TOL = 1e-4\n",
|
||||
" FLR = 1e-20\n",
|
||||
" x0 = np.log(np.ones(prb.mesh.nC)*cond)\n",
|
||||
" prb.mapping = simpeg.Maps.ExpMap(prb.mesh)\n",
|
||||
" if True:\n",
|
||||
" x0 = x0 + np.random.randn(prb.mesh.nC)*cond*1e-1 \n",
|
||||
" survey = prb.survey\n",
|
||||
" src = survey.srcList[0]\n",
|
||||
" \n",
|
||||
" u0 = prb.fields(x0)\n",
|
||||
" freq = src.freq\n",
|
||||
" A = prb.getA(freq) #\n",
|
||||
" A_I = prb.Solver(A, **prb.solverOpts)\n",
|
||||
"\n",
|
||||
" ftype = prb._fieldType + 'Solution'\n",
|
||||
" u0_src = u0[src, ftype]\n",
|
||||
" v = np.random.randn(prb.mesh.nE,1)\n",
|
||||
" \n",
|
||||
" def fun(x):\n",
|
||||
" prb.curModel = x\n",
|
||||
" return simpeg.mkvc(np.sum(prb.getRHS(freq))), lambda x: simpeg.mkvc(prb.getRHSDeriv_m(freq, x))\n",
|
||||
"# return simpeg.mkvc(prb.fields(x)[src,prb._fieldType + 'Solution']), lambda x: simpeg.mkvc(prb.getADeriv_m(freq, u0_src, x))\n",
|
||||
" return simpeg.Tests.checkDerivative(fun, x0, num=3, plotIt=False, eps=FLR)\n",
|
||||
"testDeriv_dA_dm(problem,0.1)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"==================== checkDerivative ====================\n",
|
||||
"iter h |ft-f0| |ft-f0-h*J0*dx| Order\n",
|
||||
"---------------------------------------------------------\n",
|
||||
" 0 1.00e-01 2.873e+10 3.211e+09 nan\n",
|
||||
" 1 1.00e-02 2.879e+09 3.204e+07 2.001\n",
|
||||
" 2 1.00e-03 2.882e+08 3.207e+05 2.000\n",
|
||||
"========================= PASS! =========================\n",
|
||||
"You are awesome.\n",
|
||||
"\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"def testDeriv_S_e(prb,cond):\n",
|
||||
" # Initate things for the derivs Test\n",
|
||||
" TOL = 1e-4\n",
|
||||
" FLR = 1e-20\n",
|
||||
" \n",
|
||||
" src = prb.survey.srcList[0]\n",
|
||||
" rx = src.rxList[0]\n",
|
||||
"\n",
|
||||
" x0 = np.log(np.ones(prb.mesh.nC)*cond)\n",
|
||||
"# prb.mapping = simpeg.Maps.ExpMap(prb.mesh)\n",
|
||||
" if True:\n",
|
||||
" x0 = x0 + np.random.randn(prb.mesh.nC)*cond*1e-1 \n",
|
||||
" def fun(x):\n",
|
||||
" prb.curModel = x\n",
|
||||
" return src.S_e(prb), lambda t: src.S_eDeriv_m(prb,t)\n",
|
||||
" simpeg.Tests.checkDerivative(fun,x0,num=3,plotIt=False)\n",
|
||||
"survey, problem = t3Dmt.setupSimpegMTfwd_eForm_ps(t3Dmt.random(1),comp='All',singleFreq=1)\n",
|
||||
"testDeriv_S_e(problem,0.1)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"==================== checkDerivative ====================\n",
|
||||
"iter h |ft-f0| |ft-f0-h*J0*dx| Order\n",
|
||||
"---------------------------------------------------------\n",
|
||||
" 0 1.00e-01 1.436e+01 1.792e-11 nan\n",
|
||||
" 1 1.00e-02 1.436e+00 1.792e-11 0.000\n",
|
||||
" 2 1.00e-03 1.436e-01 1.730e-11 0.015\n",
|
||||
"========================= PASS! =========================\n",
|
||||
"That was easy!\n",
|
||||
"\n",
|
||||
"==================== checkDerivative ====================\n",
|
||||
"iter h |ft-f0| |ft-f0-h*J0*dx| Order\n",
|
||||
"---------------------------------------------------------\n",
|
||||
" 0 1.00e-01 1.433e+01 1.792e-11 nan\n",
|
||||
" 1 1.00e-02 1.433e+00 1.776e-11 0.004\n",
|
||||
" 2 1.00e-03 1.433e-01 1.763e-11 0.003\n",
|
||||
"========================= PASS! =========================\n",
|
||||
"The test be workin!\n",
|
||||
"\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"def testDeriv_epx(prb):\n",
|
||||
" # Initate things for the derivs Test\n",
|
||||
" src = prb.survey.srcList[0]\n",
|
||||
" rx = src.rxList[0]\n",
|
||||
" rx.locs = np.array([[0.,0.,0,],[1.,1.,1.]])\n",
|
||||
" u0x = np.random.randn(survey.mesh.nE)+np.random.randn(survey.mesh.nE)*1j\n",
|
||||
" u0y = np.random.randn(survey.mesh.nE)+np.random.randn(survey.mesh.nE)*1j\n",
|
||||
"# u0 = np.vstack((simpeg.mkvc(u0x,2),simpeg.mkvc(u0y,2)))\n",
|
||||
" u0 = np.r_[u0x, u0y]\n",
|
||||
" f0 = prb.fieldsPair(survey.mesh,survey)\n",
|
||||
" # u0 = np.hstack((simpeg.mkvc(u0_px,2),simpeg.mkvc(u0_py,2)))\n",
|
||||
" f0[src,'e_pxSolution'] = u0[:len(u0)/2]#u0x\n",
|
||||
" f0[src,'e_pySolution'] = u0[len(u0)/2::]#u0y\n",
|
||||
" # f0[src,'b_1d'] = -1/(1j*simpegem.Utils.EMUtils.omega(src.freq))*m1d.nodalGrad*u0\n",
|
||||
" # Run a test\n",
|
||||
" def fun(u):\n",
|
||||
" f = prb.fieldsPair(survey.mesh,survey)\n",
|
||||
" f[src,'e_pxSolution'] = u[:len(u)/2]\n",
|
||||
" f[src,'e_pySolution'] = u[len(u)/2::]\n",
|
||||
" # f[src,'b_1d'] = -(m1d.nodalGrad*u)/(1j*simpegem.Utils.EMUtils.omega(src.freq))\n",
|
||||
" return f._e_px(f[src,'e_pxSolution'],[src]).ravel(), lambda t: f._e_pxDeriv_u([src],t)[:len(u0)/2].ravel()\n",
|
||||
" simpeg.Tests.checkDerivative(fun,u0,num=3,plotIt=False)\n",
|
||||
" \n",
|
||||
"def testDeriv_epy(prb):\n",
|
||||
" # Initate things for the derivs Test\n",
|
||||
" src = prb.survey.srcList[0]\n",
|
||||
" rx = src.rxList[0]\n",
|
||||
" rx.locs = np.array([[0.,0.,0,],[1.,1.,1.]])\n",
|
||||
" u0x = np.random.randn(survey.mesh.nE)+np.random.randn(survey.mesh.nE)*1j\n",
|
||||
" u0y = np.random.randn(survey.mesh.nE)+np.random.randn(survey.mesh.nE)*1j\n",
|
||||
"# u0 = np.vstack((simpeg.mkvc(u0x,2),simpeg.mkvc(u0y,2)))\n",
|
||||
" u0 = np.r_[u0x, u0y]\n",
|
||||
" f0 = prb.fieldsPair(survey.mesh,survey)\n",
|
||||
" # u0 = np.hstack((simpeg.mkvc(u0_px,2),simpeg.mkvc(u0_py,2)))\n",
|
||||
" f0[src,'e_pxSolution'] = u0[:len(u0)/2]#u0x\n",
|
||||
" f0[src,'e_pySolution'] = u0[len(u0)/2::]#u0y\n",
|
||||
" # f0[src,'b_1d'] = -1/(1j*simpegem.Utils.EMUtils.omega(src.freq))*m1d.nodalGrad*u0\n",
|
||||
" # Run a test\n",
|
||||
" def fun(u):\n",
|
||||
" f = prb.fieldsPair(survey.mesh,survey)\n",
|
||||
" f[src,'e_pxSolution'] = u[:len(u)/2]\n",
|
||||
" f[src,'e_pySolution'] = u[len(u)/2::]\n",
|
||||
" return f._e_py(f[src,'e_pySolution'],[src]).ravel(), lambda t: f._e_pyDeriv_u([src],t).ravel()\n",
|
||||
" simpeg.Tests.checkDerivative(fun,u0,num=3,plotIt=False)\n",
|
||||
" \n",
|
||||
"survey, problem = t3Dmt.setupSimpegMTfwd_eForm_ps(t3Dmt.random(.1),comp='zxyr',singleFreq=.01)\n",
|
||||
"testDeriv_epx(problem)\n",
|
||||
"testDeriv_epy(problem)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"==================== checkDerivative ====================\n",
|
||||
"iter h |ft-f0| |ft-f0-h*J0*dx| Order\n",
|
||||
"---------------------------------------------------------\n",
|
||||
" 0 1.00e-01 3.995e-01 1.107e-13 nan\n",
|
||||
" 1 1.00e-02 3.995e-02 1.105e-13 0.001\n",
|
||||
" 2 1.00e-03 3.995e-03 1.110e-13 -0.002\n",
|
||||
"========================= PASS! =========================\n",
|
||||
"The test be workin!\n",
|
||||
"\n",
|
||||
"==================== checkDerivative ====================\n",
|
||||
"iter h |ft-f0| |ft-f0-h*J0*dx| Order\n",
|
||||
"---------------------------------------------------------\n",
|
||||
" 0 1.00e-01 4.075e-01 1.086e-13 nan\n",
|
||||
" 1 1.00e-02 4.075e-02 1.049e-13 0.015\n",
|
||||
" 2 1.00e-03 4.075e-03 1.025e-13 0.010\n",
|
||||
"========================= PASS! =========================\n",
|
||||
"Happy little convergence test!\n",
|
||||
"\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"def testDeriv_bpx(prb):\n",
|
||||
" # Initate things for the derivs Test\n",
|
||||
" src = prb.survey.srcList[0]\n",
|
||||
" rx = src.rxList[0]\n",
|
||||
" rx.locs = np.array([[0.,0.,0,],[1.,1.,1.]])\n",
|
||||
" u0x = np.random.randn(survey.mesh.nE)+np.random.randn(survey.mesh.nE)*1j\n",
|
||||
" u0y = np.random.randn(survey.mesh.nE)+np.random.randn(survey.mesh.nE)*1j\n",
|
||||
"# u0 = np.vstack((simpeg.mkvc(u0x,2),simpeg.mkvc(u0y,2)))\n",
|
||||
" u0 = np.r_[u0x, u0y]\n",
|
||||
" f0 = prb.fieldsPair(survey.mesh,survey)\n",
|
||||
" # u0 = np.hstack((simpeg.mkvc(u0_px,2),simpeg.mkvc(u0_py,2)))\n",
|
||||
" f0[src,'e_pxSolution'] = u0[:len(u0)/2]#u0x\n",
|
||||
" f0[src,'e_pySolution'] = u0[len(u0)/2::]#u0y\n",
|
||||
" # f0[src,'b_1d'] = -1/(1j*simpegem.Utils.EMUtils.omega(src.freq))*m1d.nodalGrad*u0\n",
|
||||
" # Run a test\n",
|
||||
" def fun(u):\n",
|
||||
" f = prb.fieldsPair(survey.mesh,survey)\n",
|
||||
" f[src,'e_pxSolution'] = u[:len(u)/2]\n",
|
||||
" f[src,'e_pySolution'] = u[len(u)/2::]\n",
|
||||
" # f[src,'b_1d'] = -(m1d.nodalGrad*u)/(1j*simpegem.Utils.EMUtils.omega(src.freq))\n",
|
||||
" return f._b_px(f[src,'e_pxSolution'],[src]).ravel(), lambda t: f._b_pxDeriv_u(src,t).ravel()\n",
|
||||
" simpeg.Tests.checkDerivative(fun,u0,num=3,plotIt=False)\n",
|
||||
" \n",
|
||||
"def testDeriv_bpy(prb):\n",
|
||||
" # Initate things for the derivs Test\n",
|
||||
" src = prb.survey.srcList[0]\n",
|
||||
" rx = src.rxList[0]\n",
|
||||
" rx.locs = np.array([[0.,0.,0,],[1.,1.,1.]])\n",
|
||||
" u0x = np.random.randn(survey.mesh.nE)+np.random.randn(survey.mesh.nE)*1j\n",
|
||||
" u0y = np.random.randn(survey.mesh.nE)+np.random.randn(survey.mesh.nE)*1j\n",
|
||||
"# u0 = np.vstack((simpeg.mkvc(u0x,2),simpeg.mkvc(u0y,2)))\n",
|
||||
" u0 = np.r_[u0x, u0y]\n",
|
||||
" f0 = prb.fieldsPair(survey.mesh,survey)\n",
|
||||
" # u0 = np.hstack((simpeg.mkvc(u0_px,2),simpeg.mkvc(u0_py,2)))\n",
|
||||
" f0[src,'e_pxSolution'] = u0[:len(u0)/2]#u0x\n",
|
||||
" f0[src,'e_pySolution'] = u0[len(u0)/2::]#u0y\n",
|
||||
" # f0[src,'b_1d'] = -1/(1j*simpegem.Utils.EMUtils.omega(src.freq))*m1d.nodalGrad*u0\n",
|
||||
" # Run a test\n",
|
||||
" def fun(u):\n",
|
||||
" f = prb.fieldsPair(survey.mesh,survey)\n",
|
||||
" f[src,'e_pxSolution'] = u[:len(u)/2]\n",
|
||||
" f[src,'e_pySolution'] = u[len(u)/2::]\n",
|
||||
" return f._b_py(f[src,'e_pySolution'],[src]).ravel(), lambda t: f._b_pyDeriv_u(src,t).ravel()\n",
|
||||
" simpeg.Tests.checkDerivative(fun,u0,num=3,plotIt=False)\n",
|
||||
" \n",
|
||||
"survey, problem = t3Dmt.setupSimpegMTfwd_eForm_ps(t3Dmt.random(.1),comp='zyxr',singleFreq=.01)\n",
|
||||
"testDeriv_bpx(problem)\n",
|
||||
"testDeriv_bpy(problem)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# %debug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"==================== checkDerivative ====================\n",
|
||||
"iter h |ft-f0| |ft-f0-h*J0*dx| Order\n",
|
||||
"---------------------------------------------------------\n",
|
||||
" 0 1.00e-01 5.819e+11 7.675e+10 nan\n",
|
||||
" 1 1.00e-02 5.440e+10 8.852e+08 1.938\n",
|
||||
" 2 1.00e-03 5.403e+09 4.494e+07 1.294\n",
|
||||
" 3 1.00e-04 5.399e+08 4.428e+06 1.006\n",
|
||||
" 4 1.00e-05 5.399e+07 4.428e+05 1.000\n",
|
||||
" 5 1.00e-06 5.399e+06 4.428e+04 1.000\n",
|
||||
"*********************************************************\n",
|
||||
"<<<<<<<<<<<<<<<<<<<<<<<<< FAIL! >>>>>>>>>>>>>>>>>>>>>>>>>\n",
|
||||
"*********************************************************\n",
|
||||
"You break it, you fix it.\n",
|
||||
"\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from scipy.constants import mu_0\n",
|
||||
"def testDeriv_Hd(prb):\n",
|
||||
" src = prb.survey.srcList[0]\n",
|
||||
" rx = src.rxList[0]\n",
|
||||
" rx.locs = np.array([[0.,0.,0,],[1.,1.,1.]])\n",
|
||||
" u0x = np.random.randn(survey.mesh.nE)+np.random.randn(survey.mesh.nE)*1j\n",
|
||||
" u0y = np.random.randn(survey.mesh.nE)+np.random.randn(survey.mesh.nE)*1j\n",
|
||||
"# u0 = np.vstack((simpeg.mkvc(u0x,2),simpeg.mkvc(u0y,2)))\n",
|
||||
" u0 = np.r_[u0x, u0y]\n",
|
||||
" f0 = prb.fieldsPair(survey.mesh,survey)\n",
|
||||
" # u0 = np.hstack((simpeg.mkvc(u0_px,2),simpeg.mkvc(u0_py,2)))\n",
|
||||
" f0[src,'e_pxSolution'] = u0[:len(u0)/2]#u0x\n",
|
||||
" f0[src,'e_pySolution'] = u0[len(u0)/2::]#u0y\n",
|
||||
" # Run a testdef testDeriv_ZijN(rx):\n",
|
||||
" def getHdcomp(rx,f,v=None):\n",
|
||||
" if rx.locs.ndim == 3:\n",
|
||||
" eFLocs = rx.locs[:,:,0]\n",
|
||||
" bFLocs = rx.locs[:,:,1]\n",
|
||||
" else:\n",
|
||||
" eFLocs = rx.locs\n",
|
||||
" bFLocs = rx.locs\n",
|
||||
" # Get the projection\n",
|
||||
" Pbx = prb.mesh.getInterpolationMat(bFLocs,'Fx')\n",
|
||||
" Pby = prb.mesh.getInterpolationMat(bFLocs,'Fy')\n",
|
||||
" # Get the fields at location\n",
|
||||
" # px: x-polaration and py: y-polaration.\n",
|
||||
" hx_px = Pbx*f[src,'b_px']/mu_0\n",
|
||||
" hy_px = Pby*f[src,'b_px']/mu_0\n",
|
||||
" hx_py = Pbx*f[src,'b_py']/mu_0\n",
|
||||
" hy_py = Pby*f[src,'b_py']/mu_0\n",
|
||||
" # Derivatives as lambda functions\n",
|
||||
" spPe = simpeg.Utils.spzeros(rx.nD,prb.mesh.nE)\n",
|
||||
" spPb = simpeg.Utils.spzeros(rx.nD,prb.mesh.nF)\n",
|
||||
"\n",
|
||||
" # NOTE: Think b_p?Deriv_u should return a 2*nF size matrix\n",
|
||||
" hx_px_u = lambda vec: Pbx*f._b_pxDeriv_u(src,vec)/mu_0\n",
|
||||
" hy_px_u = lambda vec: Pby*f._b_pxDeriv_u(src,vec)/mu_0\n",
|
||||
" hx_py_u = lambda vec: Pbx*f._b_pyDeriv_u(src,vec)/mu_0\n",
|
||||
" hy_py_u = lambda vec: Pby*f._b_pyDeriv_u(src,vec)/mu_0\n",
|
||||
" # Update the input vector\n",
|
||||
" sdiag = lambda t: simpeg.Utils.sdiag(simpeg.mkvc(t,2))\n",
|
||||
" # Define the components of the derivative\n",
|
||||
" if v is not None:\n",
|
||||
" return (sdiag(hy_py)*hx_px_u(v)) + (sdiag(hx_px)*hy_py_u(v)) - (sdiag(hx_py)*hy_px_u(v)) - (sdiag(hy_px)*hx_py_u(v))\n",
|
||||
" else:\n",
|
||||
" return (sdiag(hx_px)*hy_py) - (sdiag(hx_py)*hy_px)\n",
|
||||
" def fun(u):\n",
|
||||
" f = prb.fieldsPair(survey.mesh,survey)\n",
|
||||
" f[src,'e_pxSolution'] = u[:len(u)/2]\n",
|
||||
" f[src,'e_pySolution'] = u[len(u)/2::]\n",
|
||||
" return getHdcomp(rx,f), lambda t: getHdcomp(rx,f0,t)\n",
|
||||
" simpeg.Tests.checkDerivative(fun,u0,num=6,plotIt=False)\n",
|
||||
"survey, problem = t3Dmt.setupSimpegMTfwd_eForm_ps(t3Dmt.random(.01),comp='zxyr',singleFreq=.0001)\n",
|
||||
"testDeriv_Hd(problem)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"==================== checkDerivative ====================\n",
|
||||
"iter h |ft-f0| |ft-f0-h*J0*dx| Order\n",
|
||||
"---------------------------------------------------------\n",
|
||||
" 0 1.00e-01 1.733e+05 7.391e+02 nan\n",
|
||||
" 1 1.00e-02 1.734e+04 6.892e+01 1.030\n",
|
||||
" 2 1.00e-03 1.734e+03 6.896e+00 1.000\n",
|
||||
" 3 1.00e-04 1.734e+02 6.896e-01 1.000\n",
|
||||
" 4 1.00e-05 1.734e+01 6.897e-02 1.000\n",
|
||||
" 5 1.00e-06 1.734e+00 6.897e-03 1.000\n",
|
||||
"*********************************************************\n",
|
||||
"<<<<<<<<<<<<<<<<<<<<<<<<< FAIL! >>>>>>>>>>>>>>>>>>>>>>>>>\n",
|
||||
"*********************************************************\n",
|
||||
"You break it, you fix it.\n",
|
||||
"\n",
|
||||
"==================== checkDerivative ====================\n",
|
||||
"iter h |ft-f0| |ft-f0-h*J0*dx| Order\n",
|
||||
"---------------------------------------------------------\n",
|
||||
" 0 1.00e-01 3.075e+05 3.072e+03 nan\n",
|
||||
" 1 1.00e-02 3.057e+04 1.202e+02 1.407\n",
|
||||
" 2 1.00e-03 3.055e+03 1.169e+01 1.012\n",
|
||||
" 3 1.00e-04 3.055e+02 1.168e+00 1.000\n",
|
||||
" 4 1.00e-05 3.055e+01 1.168e-01 1.000\n",
|
||||
" 5 1.00e-06 3.055e+00 1.168e-02 1.000\n",
|
||||
"*********************************************************\n",
|
||||
"<<<<<<<<<<<<<<<<<<<<<<<<< FAIL! >>>>>>>>>>>>>>>>>>>>>>>>>\n",
|
||||
"*********************************************************\n",
|
||||
"Did you put your clever trousers on today?\n",
|
||||
"\n",
|
||||
"==================== checkDerivative ====================\n",
|
||||
"iter h |ft-f0| |ft-f0-h*J0*dx| Order\n",
|
||||
"---------------------------------------------------------\n",
|
||||
" 0 1.00e-01 4.726e+05 1.575e+04 nan\n",
|
||||
" 1 1.00e-02 4.791e+04 1.217e+03 1.112\n",
|
||||
" 2 1.00e-03 4.797e+03 1.216e+02 1.001\n",
|
||||
" 3 1.00e-04 4.798e+02 1.216e+01 1.000\n",
|
||||
" 4 1.00e-05 4.798e+01 1.216e+00 1.000\n",
|
||||
" 5 1.00e-06 4.798e+00 1.216e-01 1.000\n",
|
||||
"*********************************************************\n",
|
||||
"<<<<<<<<<<<<<<<<<<<<<<<<< FAIL! >>>>>>>>>>>>>>>>>>>>>>>>>\n",
|
||||
"*********************************************************\n",
|
||||
"Coffee break?\n",
|
||||
"\n",
|
||||
"==================== checkDerivative ====================\n",
|
||||
"iter h |ft-f0| |ft-f0-h*J0*dx| Order\n",
|
||||
"---------------------------------------------------------\n",
|
||||
" 0 1.00e-01 4.323e+05 2.689e+04 nan\n",
|
||||
" 1 1.00e-02 4.326e+04 4.536e+02 1.773\n",
|
||||
" 2 1.00e-03 4.326e+03 3.671e+01 1.092\n",
|
||||
" 3 1.00e-04 4.327e+02 3.660e+00 1.001\n",
|
||||
" 4 1.00e-05 4.327e+01 3.660e-01 1.000\n",
|
||||
" 5 1.00e-06 4.327e+00 3.660e-02 1.000\n",
|
||||
"*********************************************************\n",
|
||||
"<<<<<<<<<<<<<<<<<<<<<<<<< FAIL! >>>>>>>>>>>>>>>>>>>>>>>>>\n",
|
||||
"*********************************************************\n",
|
||||
"No gold star for you.\n",
|
||||
"\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"def testDeriv_ZijN(prb):\n",
|
||||
" src = prb.survey.srcList[0]\n",
|
||||
" rx = src.rxList[0]\n",
|
||||
" rx.locs = np.array([[0.,0.,0,],[1.,1.,1.]])\n",
|
||||
" u0x = np.random.randn(survey.mesh.nE)+np.random.randn(prb.mesh.nE)*1j\n",
|
||||
" u0y = np.random.randn(survey.mesh.nE)+np.random.randn(prb.mesh.nE)*1j\n",
|
||||
"# u0 = np.vstack((simpeg.mkvc(u0x,2),simpeg.mkvc(u0y,2)))\n",
|
||||
" u0 = np.r_[u0x, u0y]\n",
|
||||
" f0 = prb.fieldsPair(prb.mesh,prb.survey)\n",
|
||||
" # u0 = np.hstack((simpeg.mkvc(u0_px,2),simpeg.mkvc(u0_py,2)))\n",
|
||||
" f0[src,'e_pxSolution'] = u0[:len(u0)/2]#u0x\n",
|
||||
" f0[src,'e_pySolution'] = u0[len(u0)/2::]#u0y\n",
|
||||
" def getZijNcomp(rx,f,v=None):\n",
|
||||
" if rx.locs.ndim == 3:\n",
|
||||
" eFLocs = rx.locs[:,:,0]\n",
|
||||
" bFLocs = rx.locs[:,:,1]\n",
|
||||
" else:\n",
|
||||
" eFLocs = rx.locs\n",
|
||||
" bFLocs = rx.locs\n",
|
||||
" # Get the projection\n",
|
||||
" Pex = prb.mesh.getInterpolationMat(eFLocs,'Ex')\n",
|
||||
" Pey = prb.mesh.getInterpolationMat(eFLocs,'Ey')\n",
|
||||
" Pbx = prb.mesh.getInterpolationMat(bFLocs,'Fx')\n",
|
||||
" Pby = prb.mesh.getInterpolationMat(bFLocs,'Fy')\n",
|
||||
" # Get the fields at location\n",
|
||||
" # px: x-polaration and py: y-polaration.\n",
|
||||
" ex_px = Pex*f[src,'e_px']\n",
|
||||
" ey_px = Pey*f[src,'e_px']\n",
|
||||
" ex_py = Pex*f[src,'e_py']\n",
|
||||
" ey_py = Pey*f[src,'e_py']\n",
|
||||
" hx_px = Pbx*f[src,'b_px']/mu_0\n",
|
||||
" hy_px = Pby*f[src,'b_px']/mu_0\n",
|
||||
" hx_py = Pbx*f[src,'b_py']/mu_0\n",
|
||||
" hy_py = Pby*f[src,'b_py']/mu_0\n",
|
||||
" # Derivatives as lambda functions\n",
|
||||
" # The size of the deratives should be nD,nU\n",
|
||||
" ex_px_u = lambda vec: Pex*f._e_pxDeriv_u(src,vec)\n",
|
||||
" ey_px_u = lambda vec: Pey*f._e_pxDeriv_u(src,vec)\n",
|
||||
" ex_py_u = lambda vec: Pex*f._e_pyDeriv_u(src,vec)\n",
|
||||
" ey_py_u = lambda vec: Pey*f._e_pyDeriv_u(src,vec)\n",
|
||||
" # NOTE: Think b_p?Deriv_u should return a 2*nF size matrix\n",
|
||||
" hx_px_u = lambda vec: Pbx*f._b_pxDeriv_u(src,vec)/mu_0\n",
|
||||
" hy_px_u = lambda vec: Pby*f._b_pxDeriv_u(src,vec)/mu_0\n",
|
||||
" hx_py_u = lambda vec: Pbx*f._b_pyDeriv_u(src,vec)/mu_0\n",
|
||||
" hy_py_u = lambda vec: Pby*f._b_pyDeriv_u(src,vec)/mu_0\n",
|
||||
"\n",
|
||||
" # Update the input vector\n",
|
||||
" # Define the components of the derivative# Calculate components\n",
|
||||
" # Update the input vector\n",
|
||||
" sdiag = lambda t: simpeg.Utils.sdiag(simpeg.mkvc(t,2))\n",
|
||||
" # Define the components of the derivative\n",
|
||||
" if 'zxx' in rx.rxType:\n",
|
||||
" if v is not None:\n",
|
||||
" return sdiag(hy_py)*ex_px_u(v) + sdiag(ex_px)*hy_py_u(v) - sdiag(ex_py)*hy_px_u(v) - sdiag(hy_px)*ex_py_u(v)\n",
|
||||
" return ( sdiag(ex_px)*hy_py - sdiag(ex_py)*hy_px)\n",
|
||||
" elif 'zxy' in rx.rxType:\n",
|
||||
" if v is not None:\n",
|
||||
" return -sdiag(hx_py)*ex_px_u(v) - sdiag(ex_px)*hx_py_u(v) + sdiag(ex_py)*hx_px_u(v) + sdiag(hx_px)*ex_py_u(v)\n",
|
||||
" return (-sdiag(ex_px)*hx_py + sdiag(ex_py)*hx_px)\n",
|
||||
" elif 'zyx' in rx.rxType:\n",
|
||||
" if v is not None:\n",
|
||||
" return ey_px_u(v)*hy_py + ey_px*hy_py_u(v) - ey_py*hy_px_u(v) - ey_py_u(v)*hy_px\n",
|
||||
" return ( ey_px*hy_py - ey_py*hy_px)\n",
|
||||
" elif 'zyy' in rx.rxType:\n",
|
||||
" if v is not None:\n",
|
||||
" return -ey_px_u(v)*hx_py - ey_px*hx_py_u(v) + ey_py*hx_px_u(v) + ey_py_u(v)*hx_px\n",
|
||||
" return (-ey_px*hx_py + ey_py*hx_px)\n",
|
||||
" \n",
|
||||
" def fun(u):\n",
|
||||
" f = prb.fieldsPair(survey.mesh,prb.survey)\n",
|
||||
" f[src,'e_pxSolution'] = u[:len(u)/2]\n",
|
||||
" f[src,'e_pySolution'] = u[len(u)/2::]\n",
|
||||
" return getZijNcomp(rx,f), lambda t: getZijNcomp(rx,f0,t)\n",
|
||||
" simpeg.Tests.checkDerivative(fun,u0,num=6,plotIt=False)\n",
|
||||
" \n",
|
||||
"surveyxx, problemxx = t3Dmt.setupSimpegMTfwd_eForm_ps(t3Dmt.random(.01),comp='zxxr',singleFreq=.001)\n",
|
||||
"testDeriv_ZijN(problemxx)\n",
|
||||
"surveyxy, problemxy = t3Dmt.setupSimpegMTfwd_eForm_ps(t3Dmt.random(.01),comp='zxyr',singleFreq=.0001)\n",
|
||||
"testDeriv_ZijN(problemxy)\n",
|
||||
"surveyyx, problemyx = t3Dmt.setupSimpegMTfwd_eForm_ps(t3Dmt.random(.01),comp='zyxr',singleFreq=.0001)\n",
|
||||
"testDeriv_ZijN(problemyx)\n",
|
||||
"surveyyy, problemyy = t3Dmt.setupSimpegMTfwd_eForm_ps(t3Dmt.random(.01),comp='zyyr',singleFreq=.0001)\n",
|
||||
"testDeriv_ZijN(problemyy)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# %debug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# dA_dm = problem.getADeriv_m(src.freq,u_src,w)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# dA_dm.shape"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 14,
|
||||
"metadata": {
|
||||
"collapsed": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# a, b, sig, d, e = t3Dmt.halfSpace(.01)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 40,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"==================== checkDerivative ====================\n",
|
||||
"iter h |ft-f0| |ft-f0-h*J0*dx| Order\n",
|
||||
"---------------------------------------------------------\n",
|
||||
" 0 1.00e-01 5.050e-06 1.906e-09 nan\n",
|
||||
" 1 1.00e-02 5.049e-07 1.949e-11 1.990\n",
|
||||
" 2 1.00e-03 5.048e-08 1.969e-13 1.996\n",
|
||||
" 3 1.00e-04 5.048e-09 1.377e-15 2.155\n",
|
||||
" 4 1.00e-05 5.048e-10 1.073e-15 0.108\n",
|
||||
" 5 1.00e-06 5.049e-11 4.179e-15 -0.590\n",
|
||||
" 6 1.00e-07 5.059e-12 1.079e-14 -0.412\n",
|
||||
" 7 1.00e-08 5.092e-13 4.411e-15 0.388\n",
|
||||
"========================= PASS! =========================\n",
|
||||
"Yay passed!\n",
|
||||
"\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"def testDeriv_ProjFields(prb):\n",
|
||||
" # Initate things for the derivs Test\n",
|
||||
" src = prb.survey.srcList[0]\n",
|
||||
" rx = src.rxList[0]\n",
|
||||
"# rx.locs = np.array([[0.,0.,0,],[1.,1.,1.]])\n",
|
||||
"# u0x = np.random.randn(survey.mesh.nE)+np.random.randn(survey.mesh.nE)*1j\n",
|
||||
"# u0y = np.random.randn(survey.mesh.nE)+np.random.randn(survey.mesh.nE)*1j\n",
|
||||
"# u0 = np.vstack((simpeg.mkvc(u0x,2),simpeg.mkvc(u0y,2)))\n",
|
||||
"# u0 = np.r_[u0x, u0y]\n",
|
||||
"# f0 = prb.fieldsPair(survey.mesh,survey)\n",
|
||||
" # u0 = np.hstack((simpeg.mkvc(u0_px,2),simpeg.mkvc(u0_py,2)))\n",
|
||||
"# f0[src,'e_pxSolution'] = u0[:len(u0)/2]#u0x\n",
|
||||
"# f0[src,'e_pySolution'] = u0[len(u0)/2::]#u0y\n",
|
||||
"\n",
|
||||
"# prb.mapping = simpeg.Maps.ExpMap(prb.mesh)\n",
|
||||
"# if True:\n",
|
||||
"# x0 = x0 + np.random.randn(prb.mesh.nC)*cond*1e-1 \n",
|
||||
" survey = prb.survey\n",
|
||||
" src = survey.srcList[0]\n",
|
||||
" \n",
|
||||
" f0 = prb.fields(prb.curModel)\n",
|
||||
" u0 = np.r_[f0[src,'e_pxSolution'],f0[src,'e_pySolution']]\n",
|
||||
"# def fun(x):\n",
|
||||
"# prb.curModel = x\n",
|
||||
" # f0[src,'b_1d'] = -1/(1j*simpegem.Utils.EMUtils.omega(src.freq))*m1d.nodalGrad*u0\n",
|
||||
" # Run a test\n",
|
||||
" def fun(u):\n",
|
||||
" f = prb.fieldsPair(survey.mesh,survey)\n",
|
||||
" f[src,'e_pxSolution'] = u[:len(u)/2]\n",
|
||||
" f[src,'e_pySolution'] = u[len(u)/2::]\n",
|
||||
" # f[src,'b_1d'] = -(m1d.nodalGrad*u)/(1j*simpegem.Utils.EMUtils.omega(src.freq))\n",
|
||||
" return rx.projectFields(src,survey.mesh,f), lambda t: rx.projectFieldsDeriv(src,survey.mesh,f0,t)\n",
|
||||
" simpeg.Tests.checkDerivative(fun,u0,num=8,plotIt=False)\n",
|
||||
"survey, problem = t3Dmt.setupSimpegMTfwd_eForm_ps(t3Dmt.halfSpace(1),comp='zxyr',singleFreq=.1)\n",
|
||||
"testDeriv_ProjFields(problem)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 36,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# %debug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 17,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"src = survey.srcList[0]\n",
|
||||
"rx = src.rxList[0]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 18,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"rx.locs = np.array([[0, 0, 0],[1,1,1]])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 30,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"array([ 19.30432593, 8.59301637, 7.75725432, ..., 2.18228759,\n",
|
||||
" 16.72231401, 7.67029076])"
|
||||
]
|
||||
},
|
||||
"execution_count": 30,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"problem.curModel.sigma"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 19,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"u0x = np.random.randn(survey.mesh.nE)+np.random.randn(survey.mesh.nE)*1j\n",
|
||||
"u0y = np.random.randn(survey.mesh.nE)+np.random.randn(survey.mesh.nE)*1j \n",
|
||||
"src = survey.srcList[0]\n",
|
||||
"rx = src.rxList[0]\n",
|
||||
"f0 = problem.fieldsPair(survey.mesh,survey)\n",
|
||||
"u0 = np.vstack((simpeg.mkvc(u0x,2),simpeg.mkvc(u0y,2)))\n",
|
||||
"f0[src,'e_pxSolution'] = u0x\n",
|
||||
"f0[src,'e_pySolution'] = u0y"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 20,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"(20536, 1)"
|
||||
]
|
||||
},
|
||||
"execution_count": 20,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"f0._e_px(f0[src,'e_pxSolution'],[src]).shape"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 21,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"(0, 1)"
|
||||
]
|
||||
},
|
||||
"execution_count": 21,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"f0._e_pxDeriv_u([src],u0)[len(u0)/2::].shape"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 22,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"simpeg.Utils.spzeros"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 23,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"array([[ 0.00031425],\n",
|
||||
" [ 0.00030875]])"
|
||||
]
|
||||
},
|
||||
"execution_count": 23,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"rx.projectFields(src,survey.mesh,f0)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 24,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"ERROR: No traceback has been produced, nothing to debug.\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"%debug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 2",
|
||||
"language": "python",
|
||||
"name": "python2"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 2
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython2",
|
||||
"version": "2.7.10"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
}
|
||||
@@ -0,0 +1,263 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {
|
||||
"collapsed": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Notebook to test 1D code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"collapsed": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import SimPEG as simpeg\n",
|
||||
"import simpegMT as simpegmt"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"collapsed": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"ct = 10\n",
|
||||
"m1d = simpeg.Mesh.TensorMesh([[(ct,20,-1.5),(ct,100),(ct,20,1.5)]], x0=['C'])\n",
|
||||
"sigma = np.zeros(m1d.nC) + 2e-3\n",
|
||||
"sigma[m1d.gridCC[:]>200] = 1e-8"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Make the rx and src\n",
|
||||
"freqs = np.logspace(3,-3,31)\n",
|
||||
"rxList = []\n",
|
||||
"for rxType in ['zxyr','zxyi']:\n",
|
||||
" rxList.append(simpegmt.SurveyMT.RxMT(simpeg.mkvc(np.array([405]),2).T,rxType))\n",
|
||||
"# Source list\n",
|
||||
"srcList =[]\n",
|
||||
"for freq in freqs: \n",
|
||||
" srcList.append(simpegmt.SurveyMT.srcMT(freq,rxList)) \n",
|
||||
"survey = simpegmt.SurveyMT.SurveyMT(srcList)\n",
|
||||
"problem = simpegmt.ProblemMT1D.eForm_TotalField(m1d)\n",
|
||||
"problem.pair(survey)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"fields = problem.fields(sigma)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"array([[ 1.52442595e-125 -7.20764170e-126j,\n",
|
||||
" 7.74672164e-101 +1.76864736e-100j,\n",
|
||||
" -2.07557099e-080 -3.74608600e-081j, ...,\n",
|
||||
" 3.10393307e-001 -2.86962945e-001j,\n",
|
||||
" 4.10341179e-001 -2.87349774e-001j,\n",
|
||||
" 5.05105758e-001 -2.74745005e-001j],\n",
|
||||
" [ 8.67440346e-030 +6.35706181e-030j,\n",
|
||||
" -1.53155881e-027 +3.75444030e-027j,\n",
|
||||
" -1.08396611e-024 -4.98500246e-026j, ...,\n",
|
||||
" -4.05147339e-001 +2.76576534e-001j,\n",
|
||||
" -4.96380502e-001 +2.67133906e-001j,\n",
|
||||
" -5.80363237e-001 +2.48768467e-001j],\n",
|
||||
" [ -6.16527128e-026 +8.41573172e-026j,\n",
|
||||
" -2.29821697e-023 -9.36787887e-024j,\n",
|
||||
" 1.90707675e-022 -4.18621866e-021j, ...,\n",
|
||||
" -4.75055964e-001 +2.59780137e-001j,\n",
|
||||
" -5.57847068e-001 +2.46025119e-001j,\n",
|
||||
" -6.32948088e-001 +2.25820916e-001j],\n",
|
||||
" ..., \n",
|
||||
" [ -4.42815267e-001 +4.54129730e-002j,\n",
|
||||
" -4.45450945e-001 +2.94352343e-002j,\n",
|
||||
" -4.46746292e-001 +1.94083017e-002j, ...,\n",
|
||||
" -7.96037136e-001 +1.08182287e-001j,\n",
|
||||
" -8.29064328e-001 +1.00291076e-001j,\n",
|
||||
" -8.58609530e-001 +9.06236881e-002j],\n",
|
||||
" [ -6.64333571e-001 +4.65810415e-002j,\n",
|
||||
" -6.66721482e-001 +2.99034482e-002j,\n",
|
||||
" -6.67823222e-001 +1.93821193e-002j, ...,\n",
|
||||
" -8.77622277e-001 +6.49094362e-002j,\n",
|
||||
" -8.97438594e-001 +6.01746869e-002j,\n",
|
||||
" -9.15165716e-001 +5.43742395e-002j],\n",
|
||||
" [ 1.00000000e+000 +0.00000000e+000j,\n",
|
||||
" 1.00000000e+000 +0.00000000e+000j,\n",
|
||||
" 1.00000000e+000 +0.00000000e+000j, ...,\n",
|
||||
" 1.00000000e+000 +0.00000000e+000j,\n",
|
||||
" 1.00000000e+000 +0.00000000e+000j,\n",
|
||||
" 1.00000000e+000 +0.00000000e+000j]])"
|
||||
]
|
||||
},
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"fields[:,'e_1d']"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"m1d.nN"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"self = problem\n",
|
||||
"Mmui = self.MfMui\n",
|
||||
"Msig = self.mesh.getFaceInnerProduct(self.curModel)\n",
|
||||
"C = self.mesh.nodalGrad"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"self"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"Mmui"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"self.Me[1,1]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"self.mesh.vol"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"m1d.h"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"m1d.gridCC"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 2",
|
||||
"language": "python",
|
||||
"name": "python2"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 2
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython2",
|
||||
"version": "2.7.9"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user