你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-06 20:46:52 +08:00
Merge branch 'master' of https://github.com/gprMax/gprMax
refactored some domain coordinate checking logic
这个提交包含在:
114
README.rst
114
README.rst
@@ -55,71 +55,101 @@ Package overview
|
||||
Installation
|
||||
============
|
||||
|
||||
You should use the following guidance to install gprMax if you are an end-user (i.e. you don't intend to develop or contribute to the software). Developers (or those intending to use gprMax in a HPC environment) should follow the Installation for developers section (http://docs.gprmax.com/en/latest/includereadme.html#installation-for-developers).
|
||||
The following steps provide guidance on how to install gprMax:
|
||||
|
||||
The steps are:
|
||||
1. Install Python, required Python packages, and get the gprMax source code from GitHub
|
||||
2. Install a C compiler which supports OpenMP
|
||||
3. Build and install gprMax
|
||||
|
||||
1. Get the code
|
||||
2. Install Python and required Python packages
|
||||
3. (*Microsoft Windows only*) Install C libraries
|
||||
|
||||
1. Get the code
|
||||
---------------
|
||||
|
||||
* Download the code from https://github.com/gprMax/gprMax
|
||||
|
||||
* Click on **Releases** from the top header and choose the release you want (latest is at the top).
|
||||
* Download zip files of the **source code** and **binary extensions** for your platform (``windows-32bit`` for 32-bit or ``windows-64bit`` for 64-bit versions of Microsoft Windows, ``linux-64bit`` for 64-bit versions of Linux, or ``macosx-64bit`` for 64-bit versions of Mac OS X).
|
||||
* Expand both zip files.
|
||||
* Copy the contents (binary extensions) from the ``windows-32bit``, ``windows-64bit``, ``linux-64bit`` or ``macosx-64bit`` directory into the ``gprMax-v.X.Y.Z/gprMax`` directory.
|
||||
|
||||
2. Install Python and required Python packages
|
||||
1. Install Python and required Python packages
|
||||
----------------------------------------------
|
||||
|
||||
We recommend using Miniconda to install Python and the required Python packages for gprMax in a self-contained Python environment. Miniconda is a mini version of Anaconda which is a completely free Python distribution (including for commercial use and redistribution). It includes more than 300 of the most popular Python packages for science, math, engineering, and data analysis.
|
||||
|
||||
* Install the Python 3.5 version of Miniconda for your platform from http://conda.pydata.org/miniconda.html (You can get help with installing Miniconda from http://conda.pydata.org/docs/install/quick.html)
|
||||
* Open a Terminal (Linux/Mac OS X) or Command Prompt (Windows) and navigate into the top-level gprMax directory.
|
||||
* Update conda :code:`conda update conda`
|
||||
* Create an environment (using the supplied ``conda_env.yml`` environment file) for gprMax with all the necessary Python packages :code:`conda env create -f conda_env.yml`
|
||||
* Activate the new environment :code:`source activate gprMax` (Linux/Mac OS X) or :code:`activate gprMax` (Windows).
|
||||
* Install Miniconda (Python 3.5 version) from http://conda.pydata.org/miniconda.html (help with Miniconda installation from http://conda.pydata.org/docs/install/quick.html)
|
||||
* Open a Terminal (Linux/Mac OS X) or Command Prompt (Windows) and run the following commands:
|
||||
|
||||
.. note::
|
||||
* When you are finished using gprMax the Miniconda environment can be deactivated using :code:`source deactivate` (Linux/Mac OS X) or :code:`deactivate` (Windows).
|
||||
* If you want to install Python and the required Python packages manually, i.e. without using Anaconda/Miniconda, look in the ``conda_env.yml`` file for a list of the requirements.
|
||||
.. code-block:: none
|
||||
|
||||
3. (*Microsoft Windows only*) Install C libraries
|
||||
-------------------------------------------------
|
||||
$ conda update conda
|
||||
$ conda install git
|
||||
$ git clone https://github.com/gprMax/gprMax.git
|
||||
$ cd gprMax
|
||||
$ conda env create -f conda_env.yml
|
||||
|
||||
* Install the Microsoft Visual Studio 2015 C++ Redistributable (``vc_redist.x86.exe`` for 32-bit or ``vc_redist.x64.exe`` for 64-bit) from https://www.microsoft.com/en-us/download/details.aspx?id=48145.
|
||||
This will make sure conda is up-to-date, install Git, get the latest gprMax source code from GitHub, and create an environment for gprMax with all the necessary Python packages.
|
||||
|
||||
If you prefer to install Python and the required Python packages manually, i.e. without using Anaconda/Miniconda, look in the ``conda_env.yml`` file for a list of the requirements.
|
||||
|
||||
2. Install a C compiler which supports OpenMP
|
||||
---------------------------------------------
|
||||
|
||||
Linux
|
||||
^^^^^
|
||||
|
||||
* gcc (https://gcc.gnu.org) should be already installed, so no action is required.
|
||||
|
||||
|
||||
Mac OS X
|
||||
^^^^^^^^
|
||||
|
||||
* Installations of Xcode on Mac OS X come with the LLVM (clang) compiler, but it does not currently support OpenMP, so you must install gcc (https://gcc.gnu.org). This is easily done by installing the Homebrew package manager (http://brew.sh) and running:
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
$ brew install gcc-6 --without-multilib
|
||||
|
||||
Microsoft Windows
|
||||
^^^^^^^^^^^^^^^^^
|
||||
|
||||
* Download and install Microsoft Visual C++ Build Tools 2015 directly from http://go.microsoft.com/fwlink/?LinkId=691126. Use the default installation options.
|
||||
|
||||
You can also download Microsoft Visual C++ Build Tools 2015 by going to https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx and choosing Visual Studio Downloads -> Tools for Visual Studio 2015 -> Microsoft Visual C++ Build Tools 2015.
|
||||
|
||||
3. Build and install gprMax
|
||||
---------------------------
|
||||
|
||||
Once you have installed the aforementioned tools follow these steps to build and install gprMax:
|
||||
|
||||
* Open a Terminal (Linux/Mac OS X) or Command Prompt (Windows), navigate into the top-level gprMax directory, and if it is not already active, activate the gprMax conda environment :code:`source activate gprMax` (Linux/Mac OS X) or :code:`activate gprMax` (Windows). Run the following commands:
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
(gprMax)$ python setup.py build
|
||||
(gprMax)$ python setup.py install
|
||||
|
||||
**You are now ready to proceed to running gprMax.**
|
||||
|
||||
|
||||
Running gprMax
|
||||
==============
|
||||
|
||||
* Open a Terminal (Linux/Mac OS X) or Command Prompt (Windows) and navigate into the top-level gprMax directory.
|
||||
* If it is not already active, activate the gprMax Miniconda environment :code:`source activate gprMax` (Linux/Mac OS X) or :code:`activate gprMax` (Windows)
|
||||
* gprMax in designed as a Python package, i.e. a namespace which can contain multiple packages and modules, much like a directory. Basic usage is:
|
||||
gprMax in designed as a Python package, i.e. a namespace which can contain multiple packages and modules, much like a directory.
|
||||
|
||||
Open a Terminal (Linux/Mac OS X) or Command Prompt (Windows), navigate into the top-level gprMax directory, and if it is not already active, activate the gprMax conda environment :code:`source activate gprMax` (Linux/Mac OS X) or :code:`activate gprMax` (Windows)
|
||||
|
||||
Basic usage of gprMax is:
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
python -m gprMax path_to/name_of_input_file
|
||||
(gprMax)$ python -m gprMax path_to/name_of_input_file
|
||||
|
||||
For example to run one of the test models:
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
python -m gprMax user_models/cylinder_Ascan_2D.in
|
||||
(gprMax)$ python -m gprMax user_models/cylinder_Ascan_2D.in
|
||||
|
||||
When the simulation is complete you can plot the A-scan using:
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
python -m tools.plot_Ascan user_models/cylinder_Ascan_2D.out
|
||||
(gprMax)$ python -m tools.plot_Ascan user_models/cylinder_Ascan_2D.out
|
||||
|
||||
Your results should like those from the A-scan from a metal cylinder example in introductory/basic 2D models section (http://docs.gprmax.com/en/latest/examples_simple_2D.html#view-the-results).
|
||||
|
||||
When you are finished using gprMax, the conda environment can be deactivated using :code:`source deactivate` (Linux/Mac OS X) or :code:`deactivate` (Windows).
|
||||
|
||||
Optional command line arguments
|
||||
-------------------------------
|
||||
|
||||
@@ -138,14 +168,26 @@ For example, to check the geometry of a model:
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
python -m gprMax user_models/heterogeneous_soil.in --geometry-only
|
||||
(gprMax)$ python -m gprMax user_models/heterogeneous_soil.in --geometry-only
|
||||
|
||||
For example, to run a B-scan with 60 traces:
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
python -m gprMax user_models/cylinder_Bscan_2D.in -n 60
|
||||
(gprMax)$ python -m gprMax user_models/cylinder_Bscan_2D.in -n 60
|
||||
|
||||
|
||||
Updating gprMax
|
||||
===============
|
||||
|
||||
* Open a Terminal (Linux/Mac OS X) or Command Prompt (Windows), navigate into the top-level gprMax directory, and if it is not already active, activate the gprMax conda environment :code:`source activate gprMax` (Linux/Mac OS X) or :code:`activate gprMax` (Windows). Run the following commands:
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
(gprMax)$ git pull
|
||||
(gprMax)$ python setup.py cleanall
|
||||
(gprMax)$ python setup.py build
|
||||
(gprMax)$ python setup.py install
|
||||
|
||||
This will pull the most recentr gprMax source code form GitHub, remove/clean previously built modules, and then build and install the latest version of gprMax.
|
||||
|
||||
|
@@ -7,12 +7,9 @@ dependencies:
|
||||
- cython
|
||||
- h5py
|
||||
- jupyter
|
||||
- lxml
|
||||
- matplotlib
|
||||
- mpi4py
|
||||
- numpy
|
||||
- scipy
|
||||
- lxml
|
||||
|
||||
- pip:
|
||||
- psutil
|
||||
- pyfiglet
|
||||
- psutil
|
||||
- scipy
|
二进制文件未显示。
之前 宽度: | 高度: | 大小: 61 KiB |
@@ -0,0 +1 @@
|
||||
.. include:: ../../README.rst
|
@@ -6,7 +6,7 @@ gprMax User Guide
|
||||
:maxdepth: 2
|
||||
:caption: Introduction
|
||||
|
||||
readme_install_devs
|
||||
include_readme
|
||||
features
|
||||
gprmodelling
|
||||
|
||||
|
@@ -40,12 +40,12 @@ gprMax produces a separate output file for each trace (A-scan) in the B-scan. Th
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
python -m tools.plot_Bscan outputfile output
|
||||
python -m tools.plot_Bscan outputfile rx-component
|
||||
|
||||
where:
|
||||
|
||||
* ``outputfile`` is the name of output file including the path
|
||||
* ``output`` is the name of output component (``Ex``, ``Ey``, ``Ez``, ``Hx``, ``Hy``, ``Hz``, ``Ix``, ``Iy`` or ``Iz``) to plot
|
||||
* ``rx-component`` is the name of the receiver output component (``Ex``, ``Ey``, ``Ez``, ``Hx``, ``Hy``, ``Hz``, ``Ix``, ``Iy`` or ``Iz``) to plot
|
||||
|
||||
|
||||
Antenna parameters
|
||||
@@ -54,16 +54,26 @@ Antenna parameters
|
||||
plot_antenna_params.py
|
||||
----------------------
|
||||
|
||||
This module uses matplotlib to plot the input impedance (resistance and reactance) and s11 parameter from an antenna model fed using a transmission line. It also plots the time history of the incident and reflected voltages in the transmission line and their frequency spectra. Usage (from the top-level gprMax directory) is:
|
||||
This module uses matplotlib to plot the input impedance (resistance and reactance) and s11 parameter from an antenna model fed using a transmission line. It also plots the time history of the incident and reflected voltages in the transmission line and their frequency spectra. The module can optionally plot the s21 parameter if another transmission line or a receiver output (``#rx``) is used on the receiver antenna. Usage (from the top-level gprMax directory) is:
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
python -m tools.plot_antenna_params outputfile --tln transmissionlinenumber
|
||||
python -m tools.plot_antenna_params outputfile
|
||||
|
||||
where:
|
||||
where ``outputfile`` is the name of output file including the path.
|
||||
|
||||
* ``outputfile`` is the name of output file including the path
|
||||
* ``--tln`` is the number of the transmission line (default is one). Transmission lines are numbered (starting at one) in the order they appear in the input file.
|
||||
There are optional command line arguments:
|
||||
|
||||
* ``--tltx-num`` is the number of the transmission line (default is one) for the transmitter antenna. Transmission lines are numbered (starting at one) in the order they appear in the input file.
|
||||
* ``--tlrx-num`` is the number of the transmission line (default is None) for the receiver antenna (for a s21 parameter). Transmission lines are numbered (starting at one) in the order they appear in the input file.
|
||||
* ``--rx-num`` is the number of the receiver output (default is None) for the receiver antenna (for a s21 parameter). Receivers are numbered (starting at one) in the order they appear in the input file.
|
||||
* ``--rx-component`` is the electric field component (``Ex``, ``Ey`` or ``Ez``) of the receiver output for the receiver antenna (for a s21 parameter).
|
||||
|
||||
For example to plot the input impedance, s11 and s21 parameters from a simulation with transmitter and receiver antennas that are attached to transmission lines (the transmission line feeding the transmitter appears first in the input file, and the transmission line attached to the receiver antenna appears after it).
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
python -m tools.plot_antenna_params outputfile --tltx-num 1 --tlrx-num 2
|
||||
|
||||
|
||||
.. _waveforms:
|
||||
|
@@ -1,78 +0,0 @@
|
||||
.. include:: ../../README.rst
|
||||
|
||||
.. _install-dev:
|
||||
|
||||
Installation for developers
|
||||
===========================
|
||||
|
||||
Those that are interested in developing or contributing to gprMax should use the following installation guidance:
|
||||
|
||||
1. Get the code
|
||||
2. Install Python and required Python packages
|
||||
3. Install a C compiler which supports OpenMP
|
||||
4. Compile the Cython extensions and install packages
|
||||
|
||||
1. Get the code
|
||||
---------------
|
||||
|
||||
* Use **Git** (https://git-scm.com) and clone the master branch of the repository: :code:`git clone https://github.com/gprMax/gprMax.git`
|
||||
|
||||
2. Install Python and required Python packages
|
||||
----------------------------------------------
|
||||
|
||||
We recommend using Miniconda to install Python and the required Python packages for gprMax in a self-contained Python environment. Miniconda is a mini version of Anaconda which is a completely free Python distribution (including for commercial use and redistribution). It includes more than 300 of the most popular Python packages for science, math, engineering, and data analysis.
|
||||
|
||||
* Install the Python 3.5 version of Miniconda for your platform from http://conda.pydata.org/miniconda.html (You can get help with installing Miniconda from http://conda.pydata.org/docs/install/quick.html)
|
||||
* Open a Terminal (Linux/Mac OS X) or Command Prompt (Windows) and navigate into the top-level gprMax directory.
|
||||
* Update conda :code:`conda update conda`
|
||||
* Create an environment (using the supplied ``conda_env.yml`` environment file) for gprMax with all the necessary Python packages :code:`conda env create -f conda_env.yml`
|
||||
* Activate the new environment :code:`source activate gprMax` (Linux/Mac OS X) or :code:`activate gprMax` (Windows).
|
||||
|
||||
.. note::
|
||||
* When you are finished using gprMax the Miniconda environment can be deactivated using :code:`source deactivate` (Linux/Mac OS X) or :code:`deactivate` (Windows).
|
||||
* If you want to install Python and the required Python packages manually, i.e. without using Anaconda/Miniconda, look in the ``conda_env.yml`` file for a list of the requirements.
|
||||
|
||||
|
||||
3. Install a C compiler which supports OpenMP
|
||||
---------------------------------------------
|
||||
|
||||
Linux
|
||||
^^^^^
|
||||
|
||||
* gcc (https://gcc.gnu.org) should be already installed, so no action is required.
|
||||
|
||||
|
||||
Mac OS X
|
||||
^^^^^^^^
|
||||
|
||||
* gcc (https://gcc.gnu.org) is easily installed using the Homebrew package manager (http://brew.sh) :code:`brew install gcc --without-multilib`.
|
||||
|
||||
.. note::
|
||||
|
||||
Installations of Xcode on Mac OS X come with the LLVM (clang) compiler, but it does not currently support OpenMP, so you must install gcc.
|
||||
|
||||
|
||||
Microsoft Windows
|
||||
^^^^^^^^^^^^^^^^^
|
||||
|
||||
* Download and install Microsoft Visual Studio 2015 Community (https://www.visualstudio.com/downloads/download-visual-studio-vs), which is free. Do a custom install and make sure 'Programming languages|Visual C++|Common Tools for Visual C++ 2015' is selected, no other options are required.
|
||||
|
||||
.. figure:: images/MSVS2015_install.png
|
||||
:width: 400 px
|
||||
|
||||
Screenshot of Microsoft Visual Studio 2015 Community custom install settings.
|
||||
|
||||
|
||||
4. Compile the Cython extensions and install packages
|
||||
-----------------------------------------------------
|
||||
|
||||
Once you have installed the aforementioned tools follow these steps to build the Cython extension modules for gprMax:
|
||||
|
||||
a) Open a Terminal (Linux/Mac OS X) or Command Prompt (Windows) and navigate into the top-level gprMax directory.
|
||||
b) Compile the Cython extension modules and install using: :code:`python setup.py install`. You should see a set of :code:`.c` source files and a set of :code:`.so` (Linux/Mac OS X) or :code:`.pyd` (Windows) compiled module files inside the gprMax directory.
|
||||
|
||||
.. note::
|
||||
|
||||
If you want to remove/clean Cython generated files, e.g. before rebuilding the Cython extensions, you can use :code:`python setup.py cleanall`.
|
||||
|
||||
**You are now ready to proceed to running gprMax.**
|
@@ -9,4 +9,4 @@ This section provides links to screencasts that explain how to install gprMax, d
|
||||
Installation
|
||||
------------
|
||||
|
||||
* `How to install gprMax for end users on Microsoft Windows <https://youtu.be/dvC0_7qFVbE>`_
|
||||
* `How to install gprMax for end users on Microsoft Windows <https://youtu.be/dvC0_7qFVbE>`_ -- Needs updating for new unified installation procedure (30/05/2016)
|
@@ -1,4 +1,4 @@
|
||||
# This is where the version number is set and read by setup.py and conf.py (for the docs)
|
||||
|
||||
__version__ = '3.0.0b29'
|
||||
__version__ = '3.0.0b30'
|
||||
|
||||
|
@@ -55,12 +55,12 @@ def main():
|
||||
parser = argparse.ArgumentParser(prog='gprMax', description='Electromagnetic modelling software based on the Finite-Difference Time-Domain (FDTD) method')
|
||||
parser.add_argument('inputfile', help='path to and name of inputfile')
|
||||
parser.add_argument('-n', default=1, type=int, help='number of times to run the input file')
|
||||
parser.add_argument('-mpi', action='store_true', default=False, help='switch on MPI task farm')
|
||||
parser.add_argument('-benchmark', action='store_true', default=False, help='switch on benchmarking mode')
|
||||
parser.add_argument('--geometry-only', action='store_true', default=False, help='only build model and produce geometry file(s)')
|
||||
parser.add_argument('--geometry-fixed', action='store_true', default=False, help='do not reprocess model geometry for multiple model runs')
|
||||
parser.add_argument('--write-processed', action='store_true', default=False, help='write an input file after any Python code and include commands in the original input file have been processed')
|
||||
parser.add_argument('--opt-taguchi', action='store_true', default=False, help='optimise parameters using the Taguchi optimisation method')
|
||||
parser.add_argument('-mpi', action='store_true', default=False, help='flag to switch on MPI task farm')
|
||||
parser.add_argument('-benchmark', action='store_true', default=False, help='flag to switch on benchmarking mode')
|
||||
parser.add_argument('--geometry-only', action='store_true', default=False, help='flag to only build model and produce geometry file(s)')
|
||||
parser.add_argument('--geometry-fixed', action='store_true', default=False, help='flag to not reprocess model geometry for multiple model runs')
|
||||
parser.add_argument('--write-processed', action='store_true', default=False, help='flag to write an input file after any Python code and include commands in the original input file have been processed')
|
||||
parser.add_argument('--opt-taguchi', action='store_true', default=False, help='flag to optimise parameters using the Taguchi optimisation method')
|
||||
args = parser.parse_args()
|
||||
|
||||
run_main(args)
|
||||
|
@@ -17,59 +17,107 @@
|
||||
# along with gprMax. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
"""This module contains functional forms of some of the most commonly used gprMax commands. It can be useful to use these within Python scripting in an input file."""
|
||||
"""This module contains functional forms of some of the most commonly used gprMax commands. It can be useful to use these within Python scripting in an input file.
|
||||
For convenience, x, y, z coordinates are lumped in a namedtuple Coordinate:
|
||||
>>> c = Coordinate(0.1, 0.2, 0.3)
|
||||
>>> c
|
||||
Coordinate(x=0.1, y=0.2, z=0.3)
|
||||
>>> str(c)
|
||||
'0.1 0.2 0.3'
|
||||
# which can be accessed as a normal tuple:
|
||||
>>> print c[0], c[1], c[2]
|
||||
0.1 0.2 0.3
|
||||
# or more explicitly
|
||||
>>> print c.x, c.y, c.z
|
||||
0.1 0.2 0.3
|
||||
"""
|
||||
import sys
|
||||
|
||||
from collections import namedtuple
|
||||
Coordinate_tuple = namedtuple('Coordinate', ['x', 'y', 'z'])
|
||||
|
||||
class Coordinate(Coordinate_tuple):
|
||||
"""Subclass of a namedtuple where __str__ outputs 'x y z'"""
|
||||
def __str__(self):
|
||||
return '{:g} {:g} {:g}'.format(self.x, self.y, self.z)
|
||||
|
||||
|
||||
def command(cmd, *parameters):
|
||||
"""Helper function. Prints the gprMax #<cmd>: <parameters>. None is ignored in the output.
|
||||
|
||||
Args:
|
||||
cmd (str): the gprMax cmd string to be printed
|
||||
*parameters: one or more strings as arguments, any None values are ignored
|
||||
|
||||
Returns:
|
||||
s (str): the printed string
|
||||
"""
|
||||
# remove Nones
|
||||
filtered = filter(lambda x: x is not None, parameters)
|
||||
# convert to str
|
||||
filtered_str = map(str, filtered)
|
||||
# convert to list
|
||||
filtered_list = list(filtered_str)
|
||||
try:
|
||||
s = '#{}: {}'.format(cmd, " ".join(filtered_list))
|
||||
except TypeError as e:
|
||||
# append info about cmd and parameters to the exception:
|
||||
if not e.args: e.args=('', )
|
||||
additional_info = "Creating cmd = #{} with parameters {} -> {} failed".format(cmd, parameters, filtered_list)
|
||||
e.args = e.args + (additional_info,)
|
||||
raise e
|
||||
# and now we can print it:
|
||||
print(s)
|
||||
return s
|
||||
|
||||
|
||||
def domain(x, y, z):
|
||||
"""Prints the gprMax #domain command.
|
||||
|
||||
|
||||
Args:
|
||||
x, y, z (float): Extent of the domain in the x, y, and z directions.
|
||||
|
||||
|
||||
Returns:
|
||||
domain (float): Tuple of the extent of the domain.
|
||||
domain (Coordinate): Namedtuple of the extent of the domain.
|
||||
"""
|
||||
|
||||
domain = (x, y, z)
|
||||
print('#domain: {:g} {:g} {:g}'.format(domain[0], domain[1], domain[2]))
|
||||
|
||||
domain = Coordinate(x, y, z)
|
||||
command('domain', domain)
|
||||
|
||||
return domain
|
||||
|
||||
|
||||
def dx_dy_dz(x, y, z):
|
||||
"""Prints the gprMax #dx_dy_dz command.
|
||||
|
||||
|
||||
Args:
|
||||
x, y, z (float): Spatial resolution in the x, y, and z directions.
|
||||
|
||||
|
||||
Returns:
|
||||
dx_dy_dz (float): Tuple of the spatial resolutions.
|
||||
"""
|
||||
|
||||
dx_dy_dz = (x, y, z)
|
||||
print('#dx_dy_dz: {:g} {:g} {:g}'.format(dx_dy_dz[0], dx_dy_dz[1], dx_dy_dz[2]))
|
||||
|
||||
dx_dy_dz = Coordinate(x, y, z)
|
||||
command('dx_dy_dz', dx_dy_dz)
|
||||
|
||||
return dx_dy_dz
|
||||
|
||||
|
||||
|
||||
|
||||
def time_window(time_window):
|
||||
"""Prints the gprMax #time_window command.
|
||||
|
||||
|
||||
Args:
|
||||
time_window (float): Duration of simulation.
|
||||
|
||||
|
||||
Returns:
|
||||
time_window (float): Duration of simulation.
|
||||
"""
|
||||
|
||||
print('#time_window: {:g}'.format(time_window))
|
||||
|
||||
command('time_window', time_window)
|
||||
|
||||
return time_window
|
||||
|
||||
|
||||
def material(permittivity, conductivity, permeability, magconductivity, name):
|
||||
"""Prints the gprMax #material command.
|
||||
|
||||
|
||||
Args:
|
||||
permittivity (float): Relative permittivity of the material.
|
||||
conductivity (float): Conductivity of the material.
|
||||
@@ -77,116 +125,161 @@ def material(permittivity, conductivity, permeability, magconductivity, name):
|
||||
magconductivity (float): Magnetic loss of the material.
|
||||
name (str): Material identifier.
|
||||
"""
|
||||
|
||||
print('#material: {:g} {:g} {:g} {:g} {}'.format(permittivity, conductivity, permeability, magconductivity, name))
|
||||
command('material', permittivity, conductivity, permeability, magconductivity, name)
|
||||
|
||||
|
||||
def geometry_view(xs, ys, zs, xf, yf, zf, dx, dy, dz, filename, type='n'):
|
||||
"""Prints the gprMax #geometry_view command.
|
||||
|
||||
|
||||
Args:
|
||||
xs, ys, zs, xf, yf, zf (float): Start and finish coordinates.
|
||||
dx, dy, dz (float): Spatial discretisation of geometry view.
|
||||
filename (str): Filename where geometry file information will be stored.
|
||||
type (str): Can be either n (normal) or f (fine) which specifies whether to output the geometry information on a per-cell basis (n) or a per-cell-edge basis (f).
|
||||
Returns:
|
||||
s, f, d (tuple): 3 namedtuple Coordinate for the start, finish coordinates and spatial discretisation
|
||||
"""
|
||||
|
||||
print('#geometry_view: {:g} {:g} {:g} {:g} {:g} {:g} {:g} {:g} {:g} {} {}'.format(xs, ys, zs, xf, yf, zf, dx, dy, dz, filename, type))
|
||||
s = Coordinate(xs, ys, zs)
|
||||
f = Coordinate(xf, yf, zf)
|
||||
d = Coordinate(dx, dy, dz)
|
||||
command('geometry_view', *s, *f, *d, filename, type)
|
||||
|
||||
return s, f, d
|
||||
|
||||
|
||||
def snapshot(xs, ys, zs, xf, yf, zf, dx, dy, dz, time, filename):
|
||||
"""Prints the gprMax #snapshot command.
|
||||
|
||||
|
||||
Args:
|
||||
xs, ys, zs, xf, yf, zf (float): Start and finish coordinates.
|
||||
dx, dy, dz (float): Spatial discretisation of geometry view.
|
||||
time (float): Time in seconds (float) or the iteration number (integer) which denote the point in time at which the snapshot will be taken.
|
||||
filename (str): Filename where geometry file information will be stored.
|
||||
Returns:
|
||||
s, f, d (tuple): 3 namedtuple Coordinate for the start, finish coordinates and spatial discretisation
|
||||
"""
|
||||
|
||||
if '.' in str(time) or 'e' in str(time):
|
||||
time = float(time)
|
||||
print('#snapshot: {:g} {:g} {:g} {:g} {:g} {:g} {:g} {:g} {:g} {:g} {}'.format(xs, ys, zs, xf, yf, zf, dx, dy, dz, time, filename))
|
||||
else:
|
||||
time = int(time)
|
||||
print('#snapshot: {:g} {:g} {:g} {:g} {:g} {:g} {:g} {:g} {:g} {:d} {}'.format(xs, ys, zs, xf, yf, zf, dx, dy, dz, time, filename))
|
||||
s = Coordinate(xs, ys, zs)
|
||||
f = Coordinate(xf, yf, zf)
|
||||
d = Coordinate(dx, dy, dz)
|
||||
|
||||
if '.' in str(time) or 'e' in str(time):
|
||||
time = '{:g}'.format(float(time))
|
||||
else:
|
||||
time = '{:d}'.format(int(time))
|
||||
|
||||
command('snapshot', *s, *f, *d, time, filename)
|
||||
|
||||
return s, f, d
|
||||
|
||||
|
||||
|
||||
def edge(xs, ys, zs, xf, yf, zf, material):
|
||||
"""Prints the gprMax #edge command.
|
||||
|
||||
|
||||
Args:
|
||||
xs, ys, zs, xf, yf, zf (float): Start and finish coordinates.
|
||||
material (str): Material identifier.
|
||||
Returns:
|
||||
s, f (tuple): 2 namedtuple Coordinate for the start and finish coordinates
|
||||
"""
|
||||
|
||||
print('#edge: {:g} {:g} {:g} {:g} {:g} {:g} {}'.format(xs, ys, zs, xf, yf, zf, material))
|
||||
|
||||
|
||||
s = Coordinate(xs, ys, zs)
|
||||
f = Coordinate(xf, yf, zf)
|
||||
command('edge', *s, *f, material)
|
||||
|
||||
return s, f
|
||||
|
||||
|
||||
def plate(xs, ys, zs, xf, yf, zf, material):
|
||||
"""Prints the gprMax #plate command.
|
||||
|
||||
|
||||
Args:
|
||||
xs, ys, zs, xf, yf, zf (float): Start and finish coordinates.
|
||||
material (str): Material identifier(s).
|
||||
Returns:
|
||||
s, f (tuple): 2 namedtuple Coordinate for the start and finish coordinates
|
||||
"""
|
||||
|
||||
print('#plate: {:g} {:g} {:g} {:g} {:g} {:g} {}'.format(xs, ys, zs, xf, yf, zf, material))
|
||||
|
||||
|
||||
s = Coordinate(xs, ys, zs)
|
||||
f = Coordinate(xf, yf, zf)
|
||||
command('plate', *s, *f, material)
|
||||
|
||||
return s, f
|
||||
|
||||
|
||||
def triangle(x1, y1, z1, x2, y2, z2, x3, y3, z3, thickness, material):
|
||||
"""Prints the gprMax #triangle command.
|
||||
|
||||
|
||||
Args:
|
||||
x1, y1, z1, x2, y2, z2, x3, y3, z3 (float): Coordinates of the vertices.
|
||||
thickness (float): Thickness for a triangular prism, or zero for a triangular patch.
|
||||
material (str): Material identifier(s).
|
||||
Returns:
|
||||
v1, v2, v3 (tuple): 3 namedtuple Coordinate for the vertices
|
||||
"""
|
||||
|
||||
print('#triangle: {:g} {:g} {:g} {:g} {:g} {:g} {:g} {:g} {:g} {:g} {}'.format(x1, y1, z1, x2, y2, z2, x3, y3, z3, thickness, material))
|
||||
|
||||
|
||||
v1 = Coordinate(x1, y1, z1)
|
||||
v2 = Coordinate(x2, y2, z2)
|
||||
v3 = Coordinate(x3, y3, z3)
|
||||
command('triangle', *v1, *v2, *v3, thickness, material)
|
||||
|
||||
return v1, v2, v3
|
||||
|
||||
|
||||
def box(xs, ys, zs, xf, yf, zf, material, averaging=''):
|
||||
"""Prints the gprMax #box command.
|
||||
|
||||
|
||||
Args:
|
||||
xs, ys, zs, xf, yf, zf (float): Start and finish coordinates.
|
||||
material (str): Material identifier(s).
|
||||
averaging (str): Turn averaging on or off.
|
||||
|
||||
Returns:
|
||||
s, f (tuple): 2 namedtuple Coordinate for the start and finish coordinates
|
||||
"""
|
||||
|
||||
print('#box: {:g} {:g} {:g} {:g} {:g} {:g} {} {}'.format(xs, ys, zs, xf, yf, zf, material, averaging))
|
||||
|
||||
|
||||
s = Coordinate(xs, ys, zs)
|
||||
f = Coordinate(xf, yf, zf)
|
||||
command('box', *s, *f, material, averaging)
|
||||
|
||||
return s, f
|
||||
|
||||
|
||||
def sphere(x, y, z, radius, material, averaging=''):
|
||||
"""Prints the gprMax #sphere command.
|
||||
|
||||
|
||||
Args:
|
||||
x, y, z (float): Coordinates of the centre of the sphere.
|
||||
radius (float): Radius.
|
||||
material (str): Material identifier(s).
|
||||
averaging (str): Turn averaging on or off.
|
||||
|
||||
Returns:
|
||||
c (tuple): namedtuple Coordinate for the center of the sphere
|
||||
"""
|
||||
|
||||
print('#sphere: {:g} {:g} {:g} {:g} {} {}'.format(x, y, z, radius, material, averaging))
|
||||
|
||||
|
||||
c = Coordinate(x, y, z)
|
||||
command('sphere', *c, radius, material, averaging)
|
||||
|
||||
return c
|
||||
|
||||
|
||||
def cylinder(x1, y1, z1, x2, y2, z2, radius, material, averaging=''):
|
||||
"""Prints the gprMax #cylinder command.
|
||||
|
||||
|
||||
Args:
|
||||
x1, y1, z1, x2, y2, z2 (float): Coordinates of the centres of the two faces of the cylinder.
|
||||
radius (float): Radius.
|
||||
material (str): Material identifier(s).
|
||||
averaging (str): Turn averaging on or off.
|
||||
|
||||
Returns:
|
||||
c1, c2 (tuple): 2 namedtuple Coordinate for the centres of the two faces of the cylinder.
|
||||
"""
|
||||
|
||||
print('#cylinder: {:g} {:g} {:g} {:g} {:g} {:g} {:g} {} {}'.format(x1, y1, z1, x2, y2, z2, radius, material, averaging))
|
||||
|
||||
|
||||
c1 = Coordinate(x1, y1, z1)
|
||||
c2 = Coordinate(x2, y2, z2)
|
||||
command('cylinder', *c1, *c2, radius, material, averaging)
|
||||
|
||||
return c1, c2
|
||||
|
||||
|
||||
def cylindrical_sector(axis, ctr1, ctr2, t1, t2, radius, startingangle, sweptangle, material, averaging=''):
|
||||
"""Prints the gprMax #cylindrical_sector command.
|
||||
|
||||
|
||||
Args:
|
||||
axis (str): Axis of the cylinder from which the sector is defined and can be x, y, or z.
|
||||
ctr1, ctr2 (float): Coordinates of the centre of the cylindrical sector.
|
||||
@@ -197,10 +290,99 @@ def cylindrical_sector(axis, ctr1, ctr2, t1, t2, radius, startingangle, sweptang
|
||||
material (str): Material identifier(s).
|
||||
averaging (str): Turn averaging on or off.
|
||||
"""
|
||||
|
||||
print('#cylindrical_sector: {} {:g} {:g} {:g} {:g} {:g} {:g} {:g} {} {}'.format(axis, ctr1, ctr2, t1, t2, radius, startingangle, sweptangle, material, averaging))
|
||||
|
||||
|
||||
|
||||
|
||||
command('cylindrical_sector', axis, ctr1, ctr2, t1, t2, radius, startingangle, sweptangle, material, averaging)
|
||||
|
||||
|
||||
def excitation_file(file1):
|
||||
"""Prints the #excitation_file: <file1> command.
|
||||
|
||||
Args:
|
||||
file1 (str): filename
|
||||
Returns:
|
||||
file1 (str): filename
|
||||
"""
|
||||
command('excitation_file', file1)
|
||||
|
||||
return file1
|
||||
|
||||
|
||||
def waveform(shape, amplitude, frequency, identifier):
|
||||
"""Prints the #waveform: shape amplitude frequency identifier
|
||||
|
||||
Args:
|
||||
shape (str): is the type of waveform
|
||||
amplitude (float): is the amplitude of the waveform.
|
||||
frequency (float): is the frequency of the waveform in Hertz.
|
||||
identifier (str): is an identifier for the waveform used to assign it to a source.
|
||||
Returns:
|
||||
identifier (str): is an identifier for the waveform used to assign it to a source.
|
||||
"""
|
||||
command('waveform', shape, amplitude, frequency, identifier)
|
||||
|
||||
return identifier
|
||||
|
||||
|
||||
def hertzian_dipole(polarization, f1, f2, f3, identifier, t0=None, t_remove=None):
|
||||
"""Prints the #hertzian_dipole: polarization, f1, f2, f3, identifier, [t0, t_remove]
|
||||
|
||||
Args:
|
||||
polarization (str): is the polarisation of the source and can be 'x', 'y', or 'z'.
|
||||
f1 f2 f3 (float): are the coordinates (x,y,z) of the source in the model.
|
||||
identifier (str): is the identifier of the waveform that should be used with the source.
|
||||
t0 (float): is an optinal argument for the time delay in starting the source.
|
||||
t_remove (float): is a time to remove the source.
|
||||
Returns:
|
||||
coordinates (tuple): namedtuple Coordinate of the source location
|
||||
"""
|
||||
c = Coordinate(f1, f2, f3)
|
||||
# since command ignores None, this is safe:
|
||||
command('hertzian_dipole', polarization, str(c), identifier, t0, t_remove)
|
||||
|
||||
return c
|
||||
|
||||
|
||||
def rx(x, y, z, identifier=None, to_save=None):
|
||||
"""Prints the #rx: x, y, z, [identifier, to_save] command.
|
||||
|
||||
Args:
|
||||
x, y, z (float): are the coordinates (x,y,z) of the receiver in the model.
|
||||
identifier (str): is the optional identifier of the receiver
|
||||
to_save (list): is a list of outputs with this receiver. It can be any selection from 'Ex', 'Ey', 'Ez', 'Hx', 'Hy', 'Hz', 'Ix', 'Iy', or 'Iz'.
|
||||
Returns:
|
||||
coordinates (tuple): namedtuple Coordinate of the receiver location
|
||||
"""
|
||||
c = Coordinate(x, y, z)
|
||||
command('rx', str(c), identifier, to_save)
|
||||
|
||||
return c
|
||||
|
||||
|
||||
def src_steps(dx=0, dy=0, dz=0):
|
||||
"""Prints the #src_steps: dx, dy, dz command.
|
||||
|
||||
Args:
|
||||
dx, dy, dz (float): are the increments in (x, y, z) to move all simple sources or all receivers.
|
||||
Returns:
|
||||
coordinates (tuple): namedtuple Coordinate of the increments
|
||||
"""
|
||||
|
||||
c = Coordinate(dx, dy, dz)
|
||||
command('src_steps', str(c))
|
||||
|
||||
return c
|
||||
|
||||
|
||||
def rx_steps(dx=0, dy=0, dz=0):
|
||||
"""Prints the #rx_steps: dx, dy, dz command.
|
||||
|
||||
Args:
|
||||
dx, dy, dz (float): are the increments in (x, y, z) to move all simple sources or all receivers.
|
||||
Returns:
|
||||
coordinates (tuple): namedtuple Coordinate of the increments
|
||||
"""
|
||||
|
||||
c = Coordinate(dx, dy, dz)
|
||||
command('rx_steps', str(c))
|
||||
return c
|
||||
|
||||
|
||||
|
@@ -19,8 +19,6 @@
|
||||
import sys
|
||||
import decimal as d
|
||||
|
||||
from pyfiglet import Figlet
|
||||
|
||||
|
||||
class ListStream(object):
|
||||
"""A list can be streamed into. Required when temporarily redirecting stdio to capture output from users Python code blocks."""
|
||||
@@ -56,12 +54,21 @@ GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with gprMax. If not, see <http://www.gnu.org/licenses/>."""
|
||||
|
||||
gprMaxlogo = """
|
||||
__ __
|
||||
__ _ _ __ _ __| \/ | __ ___ __
|
||||
/ _` | '_ \| '__| |\/| |/ _` \ \/ /
|
||||
| (_| | |_) | | | | | | (_| |> <
|
||||
\__, | .__/|_| |_| |_|\__,_/_/\_\\
|
||||
|___/|_|
|
||||
"""
|
||||
|
||||
width = 65
|
||||
url = 'www.gprmax.com'
|
||||
|
||||
print('\nElectromagnetic modelling software based on the Finite-Difference \nTime-Domain (FDTD) method')
|
||||
print('\n{} {} {}'.format('*'*round((width - len(url))/2), url, '*'*round((width - len(url))/2)))
|
||||
gprMaxlogo = Figlet(font='standard', width=width, justify='center')
|
||||
print('{}'.format(gprMaxlogo.renderText('gprMax')))
|
||||
print('{}'.format(gprMaxlogo))
|
||||
print('{} v{} {}'.format('*'*round((width - len(version))/2), (version), '*'*round((width - len(version))/2)))
|
||||
print(licenseinfo)
|
||||
|
||||
|
4
setup.py
4
setup.py
@@ -52,7 +52,7 @@ if sys.version_info[:2] < (3, 4):
|
||||
|
||||
# Process 'build' command line argument
|
||||
if 'build' in sys.argv:
|
||||
print("'build' is not required for this package, running 'build_ext --inplace' instead.")
|
||||
print("Running 'build_ext --inplace'")
|
||||
sys.argv.remove('build')
|
||||
sys.argv.append('build_ext')
|
||||
sys.argv.append('--inplace')
|
||||
@@ -105,7 +105,7 @@ if 'cleanall' in sys.argv:
|
||||
# Set compiler options
|
||||
# Windows
|
||||
if sys.platform == 'win32':
|
||||
compile_args = ['/O2', '/openmp', '/w']
|
||||
compile_args = ['/O2', '/openmp', '/w'] # No static linking as no static version of OpenMP library.
|
||||
linker_args = []
|
||||
extra_objects = []
|
||||
# Mac OS X - needs gcc (usually via HomeBrew) because the default compiler LLVM (clang) does not support OpenMP
|
||||
|
@@ -77,12 +77,12 @@ for ID, name in fields.items():
|
||||
|
||||
# Plot new
|
||||
fig1, ((ax1, ax2), (ax3, ax4), (ax5, ax6)) = plt.subplots(nrows=3, ncols=2, sharex=False, sharey='col', subplot_kw=dict(xlabel='Time [ns]'), num=newfile + ' versus ' + oldfile, figsize=(20, 10), facecolor='w', edgecolor='w')
|
||||
ax1.plot(timenew, new[:,0],'r', lw=2, label='Ex')
|
||||
ax3.plot(timenew, new[:,2],'r', lw=2, label='Ey')
|
||||
ax5.plot(timenew, new[:,4],'r', lw=2, label='Ez')
|
||||
ax2.plot(timenew, new[:,1],'b', lw=2, label='Hx')
|
||||
ax4.plot(timenew, new[:,3],'b', lw=2, label='Hy')
|
||||
ax6.plot(timenew, new[:,5],'b', lw=2, label='Hz')
|
||||
ax1.plot(timenew, new[:,0],'r', lw=2, label='Ex')
|
||||
ax3.plot(timenew, new[:,2],'r', lw=2, label='Ey')
|
||||
ax5.plot(timenew, new[:,4],'r', lw=2, label='Ez')
|
||||
ax2.plot(timenew, new[:,1],'b', lw=2, label='Hx')
|
||||
ax4.plot(timenew, new[:,3],'b', lw=2, label='Hy')
|
||||
ax6.plot(timenew, new[:,5],'b', lw=2, label='Hz')
|
||||
|
||||
# Set ylabels
|
||||
ylabels = ['$E_x$, field strength [V/m]', '$H_x$, field strength [A/m]', '$E_y$, field strength [V/m]', '$H_y$, field strength [A/m]', '$E_z$, field strength [V/m]', '$H_z$, field strength [A/m]']
|
||||
@@ -103,12 +103,12 @@ for index, ax in enumerate(fig1.axes):
|
||||
|
||||
# Plots of differences
|
||||
fig2, ((ax1, ax2), (ax3, ax4), (ax5, ax6)) = plt.subplots(nrows=3, ncols=2, sharex=False, sharey='col', subplot_kw=dict(xlabel='Time [ns]'), num='Deltas: ' + newfile + ' versus ' + oldfile, figsize=(20, 10), facecolor='w', edgecolor='w')
|
||||
ax1.plot(timenew[:timesmallest], diffs[:,0],'r', lw=2, label='Ex')
|
||||
ax3.plot(timenew[:timesmallest], diffs[:,2],'r', lw=2, label='Ey')
|
||||
ax5.plot(timenew[:timesmallest], diffs[:,4],'r', lw=2, label='Ez')
|
||||
ax2.plot(timenew[:timesmallest], diffs[:,1],'b', lw=2, label='Hx')
|
||||
ax4.plot(timenew[:timesmallest], diffs[:,3],'b', lw=2, label='Hy')
|
||||
ax6.plot(timenew[:timesmallest], diffs[:,5],'b', lw=2, label='Hz')
|
||||
ax1.plot(timenew[:timesmallest], diffs[:,0],'r', lw=2, label='Ex')
|
||||
ax3.plot(timenew[:timesmallest], diffs[:,2],'r', lw=2, label='Ey')
|
||||
ax5.plot(timenew[:timesmallest], diffs[:,4],'r', lw=2, label='Ez')
|
||||
ax2.plot(timenew[:timesmallest], diffs[:,1],'b', lw=2, label='Hx')
|
||||
ax4.plot(timenew[:timesmallest], diffs[:,3],'b', lw=2, label='Hy')
|
||||
ax6.plot(timenew[:timesmallest], diffs[:,5],'b', lw=2, label='Hz')
|
||||
|
||||
# Set ylabels
|
||||
ylabels = ['$E_x$', '$H_x$', '$E_y$', '$H_y$', '$E_z$', '$H_z$']
|
||||
|
二进制文件未显示。
之后 宽度: | 高度: | 大小: 25 KiB |
@@ -146,8 +146,8 @@
|
||||
"# Maximum spatial resolution\n",
|
||||
"dmin = wmin / 10\n",
|
||||
"\n",
|
||||
"print('Minimum wavelength = {:g}m'.format(wmin))\n",
|
||||
"print('Maximum spatial resolution = {:g}m'.format(dmin))"
|
||||
"print('Minimum wavelength: {:g} m'.format(wmin))\n",
|
||||
"print('Maximum spatial resolution: {:g} m'.format(dmin))"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
文件差异因一行或多行过长而隐藏
文件差异因一行或多行过长而隐藏
@@ -210,8 +210,8 @@ def mpl_plot(filename, outputs=Rx.availableoutputs, fft=False):
|
||||
ax.grid()
|
||||
|
||||
# Save a PDF/PNG of the figure
|
||||
#fig.savefig(os.path.splitext(os.path.abspath(file))[0] + '_rx' + str(rx) + '.pdf', dpi=None, format='pdf', bbox_inches='tight', pad_inches=0.1)
|
||||
#fig.savefig(os.path.splitext(os.path.abspath(file))[0] + '_rx' + str(rx) + '.png', dpi=150, format='png', bbox_inches='tight', pad_inches=0.1)
|
||||
#fig.savefig(os.path.splitext(os.path.abspath(filename))[0] + '_rx' + str(rx) + '.pdf', dpi=None, format='pdf', bbox_inches='tight', pad_inches=0.1)
|
||||
#fig.savefig(os.path.splitext(os.path.abspath(filename))[0] + '_rx' + str(rx) + '.png', dpi=150, format='png', bbox_inches='tight', pad_inches=0.1)
|
||||
|
||||
return plt
|
||||
|
||||
|
@@ -101,7 +101,7 @@ if __name__ == "__main__":
|
||||
# Parse command line arguments
|
||||
parser = argparse.ArgumentParser(description='Plots a B-scan image.', usage='cd gprMax; python -m tools.plot_Bscan outputfile output')
|
||||
parser.add_argument('outputfile', help='name of output file including path')
|
||||
parser.add_argument('rx_component', help='name of output component to be plotted', choices=['Ex', 'Ey', 'Ez', 'Hx', 'Hy', 'Hz', 'Ix', 'Iy', 'Iz'])
|
||||
parser.add_argument('rx-component', help='name of output component to be plotted', choices=['Ex', 'Ey', 'Ez', 'Hx', 'Hy', 'Hz', 'Ix', 'Iy', 'Iz'])
|
||||
args = parser.parse_args()
|
||||
|
||||
# Open output file and read number of outputs (receivers)
|
||||
|
@@ -25,12 +25,13 @@ import matplotlib.gridspec as gridspec
|
||||
from gprMax.exceptions import CmdInputError
|
||||
|
||||
|
||||
def calculate_antenna_params(filename, tlnumber=1, rxnumber=None, rxcomponent=None):
|
||||
def calculate_antenna_params(filename, tltxnumber=1, tlrxnumber=None, rxnumber=None, rxcomponent=None):
|
||||
"""Calculates antenna parameters - incident, reflected and total volatges and currents; s11, (s21) and input impedance.
|
||||
|
||||
Args:
|
||||
filename (string): Filename (including path) of output file.
|
||||
tlnumber (int): Transmitting antenna - transmission line number
|
||||
tltxnumber (int): Transmitter antenna - transmission line number
|
||||
tlrxnumber (int): Receiver antenna - transmission line number
|
||||
rxnumber (int): Receiver antenna - output number
|
||||
rxcomponent (str): Receiver antenna - output electric field component
|
||||
|
||||
@@ -53,23 +54,27 @@ def calculate_antenna_params(filename, tlnumber=1, rxnumber=None, rxcomponent=No
|
||||
print('Time step: {:g} s'.format(dt))
|
||||
print('Frequency bin spacing: {:g} Hz'.format(df))
|
||||
|
||||
# Read/calculate voltages and currents
|
||||
tlpath = '/tls/tl' + str(tlnumber) + '/'
|
||||
# Read/calculate voltages and currents from transmitter antenna
|
||||
tltxpath = '/tls/tl' + str(tltxnumber) + '/'
|
||||
|
||||
# Incident voltages/currents
|
||||
Vinc = f[tlpath + 'Vinc'][:]
|
||||
Iinc = f[tlpath + 'Iinc'][:]
|
||||
Vinc = f[tltxpath + 'Vinc'][:]
|
||||
Iinc = f[tltxpath + 'Iinc'][:]
|
||||
|
||||
# Total (incident + reflected) voltages/currents
|
||||
Vtotal = f[tlpath +'Vtotal'][:]
|
||||
Itotal = f[tlpath +'Itotal'][:]
|
||||
Vtotal = f[tltxpath +'Vtotal'][:]
|
||||
Itotal = f[tltxpath +'Itotal'][:]
|
||||
|
||||
# Reflected voltages/currents
|
||||
Vref = Vtotal - Vinc
|
||||
Iref = Itotal - Iinc
|
||||
|
||||
# If a receiver number for a receiever antenna is given can get received voltage for s21
|
||||
if rxnumber:
|
||||
# If a receiver antenna is used (with a transmission line or receiver), get received voltage for s21
|
||||
if tlrxnumber:
|
||||
tlrxpath = '/tls/tl' + str(tlrxnumber) + '/'
|
||||
Vrec = f[tlrxpath +'Vtotal'][:]
|
||||
|
||||
elif rxnumber:
|
||||
rxpath = '/rxs/rx' + str(rxnumber) + '/'
|
||||
availableoutputs = list(f[rxpath].keys())
|
||||
|
||||
@@ -95,7 +100,7 @@ def calculate_antenna_params(filename, tlnumber=1, rxnumber=None, rxcomponent=No
|
||||
|
||||
# Calculate s11 and (optionally) s21
|
||||
s11 = np.abs(np.fft.fft(Vref) * delaycorrection) / np.abs(np.fft.fft(Vinc) * delaycorrection)
|
||||
if rxnumber:
|
||||
if tlrxnumber or rxnumber:
|
||||
s21 = np.abs(np.fft.fft(Vrec)) / np.abs(np.fft.fft(Vinc) * delaycorrection)
|
||||
|
||||
# Calculate input impedance
|
||||
@@ -118,17 +123,18 @@ def calculate_antenna_params(filename, tlnumber=1, rxnumber=None, rxcomponent=No
|
||||
'Vref': Vref, 'Vrefp': Vrefp, 'Iref': Iref, 'Irefp': Irefp,
|
||||
'Vtotal': Vtotal, 'Vtotalp': Vtotalp, 'Itotal': Itotal, 'Itotalp': Itotalp,
|
||||
's11': s11, 'zin': zin, 'yin': yin}
|
||||
if rxnumber:
|
||||
if tlrxnumber or rxnumber:
|
||||
s21 = 20 * np.log10(s21)
|
||||
antennaparams['s21'] = s21
|
||||
|
||||
return antennaparams
|
||||
|
||||
|
||||
def mpl_plot(time, freqs, Vinc, Vincp, Iinc, Iincp, Vref, Vrefp, Iref, Irefp, Vtotal, Vtotalp, Itotal, Itotalp, s11, zin, yin, s21=None):
|
||||
def mpl_plot(filename, time, freqs, Vinc, Vincp, Iinc, Iincp, Vref, Vrefp, Iref, Irefp, Vtotal, Vtotalp, Itotal, Itotalp, s11, zin, yin, s21=None):
|
||||
"""Plots antenna parameters - incident, reflected and total volatges and currents; s11, (s21) and input impedance.
|
||||
|
||||
Args:
|
||||
filename (string): Filename (including path) of output file.
|
||||
time (array): Simulation time.
|
||||
freq (array): Frequencies for FFTs.
|
||||
Vinc, Vincp, Iinc, Iincp (array): Time and frequency domain representations of incident voltage and current.
|
||||
@@ -159,7 +165,7 @@ def mpl_plot(time, freqs, Vinc, Vincp, Iinc, Iincp, Vref, Vrefp, Iref, Irefp, Vt
|
||||
|
||||
# Figure 1
|
||||
# Plot incident voltage
|
||||
fig1, ax = plt.subplots(num='Transmission line parameters', figsize=(20, 12), facecolor='w', edgecolor='w')
|
||||
fig1, ax = plt.subplots(num='Transmitter transmission line parameters', figsize=(20, 12), facecolor='w', edgecolor='w')
|
||||
gs1 = gridspec.GridSpec(4, 2, hspace=0.7)
|
||||
ax = plt.subplot(gs1[0, 0])
|
||||
ax.plot(time, Vinc, 'r', lw=2, label='Vinc')
|
||||
@@ -304,7 +310,7 @@ def mpl_plot(time, freqs, Vinc, Vincp, Iinc, Iincp, Vref, Vrefp, Iref, Irefp, Vt
|
||||
ax.grid()
|
||||
|
||||
# Plot frequency spectra of s21
|
||||
if s21:
|
||||
if s21 is not None:
|
||||
ax = plt.subplot(gs2[0, 1])
|
||||
markerline, stemlines, baseline = ax.stem(freqs[pltrange], s21[pltrange], '-.')
|
||||
plt.setp(baseline, 'linewidth', 0)
|
||||
@@ -389,12 +395,13 @@ if __name__ == "__main__":
|
||||
# Parse command line arguments
|
||||
parser = argparse.ArgumentParser(description='Plots antenna parameters (s11, s21 parameters and input impedance) from an output file containing a transmission line source.', usage='cd gprMax; python -m tools.plot_antenna_params outputfile')
|
||||
parser.add_argument('outputfile', help='name of output file including path')
|
||||
parser.add_argument('--tl-num', default=1, type=int, help='transmitting antenna - transmission line number')
|
||||
parser.add_argument('--tltx-num', default=1, type=int, help='transmitter antenna - transmission line number')
|
||||
parser.add_argument('--tlrx-num', type=int, help='receiver antenna - transmission line number')
|
||||
parser.add_argument('--rx-num', type=int, help='receiver antenna - output number')
|
||||
parser.add_argument('--rx-component', type=str, help='receiver antenna - output electric field component', choices=['Ex', 'Ey', 'Ez'])
|
||||
args = parser.parse_args()
|
||||
|
||||
antennaparams = calculate_antenna_params(args.outputfile, args.tl_num, args.rx_num, args.rx_component)
|
||||
plt = mpl_plot(**antennaparams)
|
||||
antennaparams = calculate_antenna_params(args.outputfile, args.tltx_num, args.tlrx_num, args.rx_num, args.rx_component)
|
||||
plt = mpl_plot(args.outputfile, **antennaparams)
|
||||
plt.show()
|
||||
|
||||
|
@@ -24,9 +24,12 @@ optparamsinit = pickle.load(f)
|
||||
print('Optimisations summary for: {}'.format(os.path.split(args.picklefile)[1]))
|
||||
print('Number of iterations: {:g}'.format(len(fitnessvalueshist)))
|
||||
print('History of fitness values: {}'.format(fitnessvalueshist))
|
||||
print('Initial parameter values:')
|
||||
for item in optparamsinit:
|
||||
print('\t{}: {}'.format(item[0], item[1]))
|
||||
print('History of parameter values:')
|
||||
for key, value in optparamshist.items():
|
||||
print(key, value)
|
||||
print('\t{}: {}'.format(key, value))
|
||||
|
||||
|
||||
# Plot the history of fitness values and each optimised parameter values for the optimisation
|
||||
|
53
user_models/cylinder_2D_py.in
普通文件
53
user_models/cylinder_2D_py.in
普通文件
@@ -0,0 +1,53 @@
|
||||
#python:
|
||||
from gprMax.input_cmd_funcs import *
|
||||
command('title', 'A or B scan from a metal cylinder buried in a dielectric half-space')
|
||||
z_dim = 0.002
|
||||
resolution = 0.002
|
||||
tsim = 3e-9
|
||||
B_scan = False
|
||||
|
||||
domain = domain(x=64e-2, y=30e-2, z=z_dim)
|
||||
dx = dx_dy_dz(resolution, resolution, z_dim)
|
||||
time_window(tsim)
|
||||
|
||||
material(permittivity=6, conductivity=0,
|
||||
permeability=1, magconductivity=0, name='half_space')
|
||||
|
||||
identifier = waveform('ricker', amplitude=1, frequency=1.5e9,
|
||||
identifier='my_ricker')
|
||||
|
||||
if B_scan:
|
||||
x_ant = 8e-2
|
||||
else:
|
||||
x_ant = domain.x/2 - 1e-2 # in the middle of the x-axis
|
||||
|
||||
tx = hertzian_dipole('z',
|
||||
x_ant, domain.y - 4e-2, 0, # minus 4 cm in y-direction
|
||||
identifier)
|
||||
rx(tx.x + 2e-2, tx.y, tx.z) # 2 cm away in x-direction from tx
|
||||
|
||||
if B_scan:
|
||||
src_steps(dx=0.8e-2/4)
|
||||
rx_steps(dx=0.8e-2/4)
|
||||
|
||||
b0, b1 = box(0, 0, 0,
|
||||
domain.x, domain.y - 4e-2, z_dim, # same as domain, minus 4 cm in y-direction
|
||||
'half_space')
|
||||
|
||||
c_x, c_y = (domain.x/2, b1.y - 5e-2) # in the middle of the x-axis and 5 cm down from the half_space
|
||||
cylinder(c_x, c_y, 0,
|
||||
c_x, c_y, z_dim,
|
||||
radius=1e-2, material='pec')
|
||||
|
||||
# Outputs, geometry and snapshots
|
||||
geometry_view(0, 0, 0,
|
||||
domain.x, domain.y, domain.z,
|
||||
dx.x, dx.y, dx.z,
|
||||
'cylinder', 'n')
|
||||
|
||||
N = 32
|
||||
for i in range(1, N+1):
|
||||
snapshot(0, 0, 0,
|
||||
domain.x, domain.y, domain.z,
|
||||
dx.x, dx.y, dx.z, i*(tsim/N), 'snapshot' + str(i))
|
||||
#end_python:
|
在新工单中引用
屏蔽一个用户