Package to interact with FastCycles
Project description
PythonFastCycles
This is a Python package to interact with the the Fortran code FastCycles.
FastCycles has been developped by Pierre Romanet during his PhD thesis under the direction of R. Madariaga and H. Bhat.
See Romanet et al. (2018). [1]
Install
You can install the lastest version of PythonFastCycles using pip.
Run in a terminal:
pip install PythonFastCycles
How to use
Create files for a simulation
Defines path to a simulation folder
path = 'path/to/fastcycles/problems/'
Defines parameters
fric_law = 'RateStateAgeing_R'
frac_mode = 'ModeIII'
mu = 3e10
Dc = 1e-3
sigma_N = -1e8
a = 0.0075
b = 0.01
The lenght of the fault L is defined with the ratio L/Lnuc (Lnuc is computed automatically).
L_over_Lnuc = 2
Defines σ
s11 = 0.0
s22 = 0.0
s33 = 0.0
s12 = 0.0
s13 = 0.0
s23 = 0.1
sigma_dot = np.array([[s11, s12, s13], [s12, s22, s23], [s13, s23, s33]])
Create a simulation 'test'
First initialise the simulation
test = Simulation(path, 'Test', mu, a, b, fric_law=fric_law, frac_mode=frac_mode, sigma_N=sigma_N, Dc=Dc)
You can thus create all files (i.e. config.in, geometry.in, GPS.in and tides.in) using :
test.create_all_files(L_over_Lnuc, sigma_dot, geom_type='1fault')
Parameters that can be parse to this function:
-
geom_type specifies the geometry of your fault system. For now you can only choose from:
-
"1fault", a geometry with a single fault of length L defines with L/Lnuc
-
"2faults_overlapping", the geometry of Romanet et al. (2018), GRL. You can then specify:
- D/Lnuc with D_over_Lnuc
- the overlap (L/(2Lnuc in the figure below) the parameter overlap
-
"multiple", a geometry with multiple faults defined with a length, an angle and the distance in x and y of one edge from the first fault
- lengths is a vector with the lengths of the faults normalised by Lnuc (L/Lnuc). It has size n, with n the number of fault.
- angles is a vector with the orientation of the faults. The angle is positive in the trigonometric direction. It has size n.
- xs is the distance in x normalized by Lnuc between the edge defining the fault and the first fault. Hence it has size n-1.
- ys is the distance in y normalized by Lnuc between the edge defining the fault and the first fault. Hence it has size n-1.
-
-
stop_crit can be 0, 1 or 2.
- stop_crit = 0: simulation will stop after the first event
- stop_crit = 1: simulation will stop after max_it iterations
- stop_crit = 2: simulation will stop at final_time
- GPSx and GPSy, two lists with the GPS stations coordinates. By default there is only one GPS station at (10, 10).
- Tampli, Tperiod, Tphase, three lists uses to impose tides. By default there is no tides.
- Vval_x1 and Vval_x2, x coordinates delimiting the portion on the fault on which the initial perturbation is imposed
- Vval_pourc, the amplitude of the perturbation
Instead of creating all files at once, you can choose to create just one file.
The following code lines are doing exactly the same thing as:
test.create_all_files(L_over_Lnuc, sigma_dot, geom_type='1fault', stop_crit=1, max_it=10000)
# Creates tides.in with default values of tides (i.e. no tides)
test.create_tides_file()
# Creates GPS.in with default values (one GPS station at (10, 10))
test.create_GPS_file()
# Creates geometry.in for a single fault
test.create_geom_1fault(0, test.Lnuc * test.L_over_Lnuc)
# Creates config.in file with default values
test.create_config_file(sigma_dot)
When you create a geometry, you can add the argument show=True to the function to plot the geometry.
Reading and processing simulation data
First we need to read output files:
Test = ReadData(path/to/simulation/folder)
Plot the geometry of the fault system:
Test.plot_geometry()
By default axis are normalised by Lnuc but you can add the argument scale='X' to have coordinates in meters.
Plot the maximum velocity for all faults:
Test.plot_max_vel()
You can choose the location of horizontal earthquake and SSE limits with eql and ssel arguments. Default is eql=1e-3, ssel=1e-8.
Plot slip rate evolution
Test.plot_slip_rate()
With vmask you can specify a value under which all data will be display as white.
Plot moment rate evolution
Test.plot_moment_rate()
Plot GPS rate evolution
Test.plot_GPS_rate()
Plot GPS displacements
Test.plot_GPS_disp()
By default all GPS stations are plot in the save graph. With the argument plot_type='each' each GPS station will be displayed in a subplot.
Aditional arguments
- For all this functions, to plot data between a and b indices you can specify a
start=aand/or astop=bargument(s). - By default figures are saved in the simulation directory. You can specify
savefig=Falseis you don't want to save them.
Fixing simulations' problems
Sometimes, the maximum slip rate in 'MomentRate.out' is '-Infinity' and the moment rate is 'nan'. It is due to a wrong tolerance criteria for the adaptive time step. For the moment there is no way to know it before running the simulation, and it has to be manually modified afterwards. The tolerance criteria is denoted as tol_solver and can be set in 'config.in'.
The class FixSimulations check if simulations have '-Infinity' maximum slip rate and can modify the tolerance criteria.
All you have to do is:
fix = FixSimulations(path, simunames)
with path the path to the simulations directory and simunames a list with the names of the simulations to check.
For example:
simunames= ['simu1', 'simu2', 'simu3']
You will then be asked if you want to automatically change tol_solver. Press y to do so and press y again to relaunch simulations.
tol_solver will be decreased by an order of magnitude but it might not be sufficient. You can thus redo the manipulation to decrease it further down.
If you press n you will exit the function but you can still find the simulations that need to be changed using:
fix.simu_affected
Miscellaneous functions
find_simunames
find_simunames(path, regex) finds all simulations in the directory path matching the expression regex. For example:
find_simunames(path, '^simu3\d')
will search all simulations with name starting by 'simu3' and a digit (simu30, simu31, ..., simu39).
You can type help(find_simunames) to see common regex syntax.
References
[1] Romanet et al. (2018). ast and slow slip events emerge due to fault geometrical complexity. Geophysical Research Letters, 45(10), pp.4809-4819 https://doi.org/10.1029/2018GL077579
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file PythonFastCycles-1.0.11.tar.gz.
File metadata
- Download URL: PythonFastCycles-1.0.11.tar.gz
- Upload date:
- Size: 1.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.6.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1a78edd785aa1f11c67a28fe52ad9b6b137a5fd1b8b970d98bfe16a144cc81f
|
|
| MD5 |
b51ed7f7563d2b706b69d719ebc2a62c
|
|
| BLAKE2b-256 |
5926f33d4b5423f27055c92bba4dd5e213fc52c92f59674606e0120735bfdca8
|
File details
Details for the file PythonFastCycles-1.0.11-py3-none-any.whl.
File metadata
- Download URL: PythonFastCycles-1.0.11-py3-none-any.whl
- Upload date:
- Size: 46.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.6.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6b7aa01e9674994205da486492382494255769d512bbff033512f1f0b5fa575
|
|
| MD5 |
8b7499802138d7aae26037ca3b7aaf1e
|
|
| BLAKE2b-256 |
70773d021a0a79c33d682609ab57a8a4ba943cd52572d51007495720cfcc2e79
|