Giter VIP home page Giter VIP logo

pystrata's Introduction

pyStrata

Python library for site response analysis.

PyPI GitHub Workflow Status Read the Docs Codacy coverage License Zenodo MyBinder

Introduction

Site response analyses implemented in Python. This Python packages aims to implement many of the features found in Strata. These features include:

  • Input motion characterization:
    • Time series
    • Random vibration theory
  • Wave propagation or site amplification:
    • linear
    • equivalent-linear
    • equivalent-linear with frequency dependent properties
    • quarter wavelength
  • Nonlinear curve models:
    • Predictive models:
      • Darendeli (2001)
      • Menq (2004)
      • Kishida (2012)
    • Curves:
      • Vucetic & Dobry (1991)
      • EPRI (1993)
      • GEI (1983)
      • GeoMatrix (1990)
      • Idriss (1990)
      • Imperial Valley Soils
      • Iwasaki
      • Peninsular Range
      • Seed & Idriss
  • Site and soil property uncertainty:
    • Toro (1994) Vs correlation model
    • G/Gmax and D uncertainty:
    • Darendeli (2001)
    • EPRI SPID (2013)

Development of this software is on-going and any contributions are encouraged. Previously named pysra, but renamed after some sage and persistent advice to be better associated with Strata.

Installation

pystrata is available via pip and can be installed with:

pip install pystrata

If you are using conda and a create a pystrata specific environmental make sure you install ipykernels and nb_conda_kernels so that the environment is discoverable by Jupyter with:

conda install ipykernel nb_conda_kernels

Citation

Please cite this software using the following DOI:

Albert Kottke & Maxim Millen. (2023). arkottke/pystrata: v0.5.2 (v0.5.2). Zenodo. https://doi.org/10.5281/zenodo.7551992

or with BibTeX:

@software{albert_kottke_2023_7551992,
  author       = {Albert Kottke and
                  Maxim Millen},
  title        = {arkottke/pystrata: v0.5.2},
  month        = jan,
  year         = 2023,
  publisher    = {Zenodo},
  version      = {v0.5.2},
  doi          = {10.5281/zenodo.7551992},
  url          = {https://doi.org/10.5281/zenodo.7551992}
}

Examples

There are a variety of examples of using pystrata within the examples directory. An interactive Jupyter interface of these examples is available on MyBinder.

pystrata's People

Contributors

arkottke avatar millen1m avatar stickler-ci avatar subsurfaceiodev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pystrata's Issues

Menq dynamic curve IMPORTANT ISSUE

_calc_damping_min and _calc_strain_ref functions are using _stress_mean in kPa! This value must be converted to ATM: change _stress_mean for (_stress_mean * KPA_TO_ATM)

Error in executing example 6

I got this error while running the example 6 given in PYSRA:

Traceback (most recent call last):
File "", line 1, in
File "", line 20, in iter_geopsy_profiles
File "", line 20, in
NameError: name 'floa4t' is not defined

It was shown when executing this command:

fname = 'data/best100_GM_linux.txt'

for geopsy_profile in iter_geopsy_profiles(fname):
profile = pysra.site.Profile([
pysra.site.Layer(
pysra.site.SoilType(
'soil-%d' % i, l['density'] / pysra.site.GRAVITY,
damping=0.05), l['thickness'], l['vel_shear'])
for i, l in enumerate(geopsy_profile['layers'])
])
# Use 1% damping for the half-space
profile[-1].soil_type.damping = 0.01
# Compute the waves from the last layer
calc(ts, profile, profile.location('outcrop', index=-1))
# Compute the site amplification
outputs(calc)

The above was while running in python.

While running in Jupyter notebook, below error was shown:
TypeError Traceback (most recent call last)
in
18 pysra.output.OutputLocation('outcrop', index=0),
19 # Damping
---> 20 0.05
21 ),
22

TypeError: init() takes 2 positional arguments but 3 were given

This was while executing the commands given in In[12] in the example 6.

Installation issues

Installing pystrata on my various machines has resulted in several issues. The most common one is that it says pyexcel is needed when importing pystrata.

This is what I've found to be the most successful way of installing pystrata
conda create --name pystrata python=3.9 spyder-kernels=2.1.0 pandas pyexcel
pip install pystrata

This allows pystrata to be successfully imported, but when launching spyder in the environment there are a handful of matplotlib warnings that can be solved by also running this in the environment
pip3 install PyQt5

How to use non-Darendeli nonlinear properties

I have been able to reproduce the nonlinear EQL examples given on the website using pystrata.site.DarendeliSoilType layers. However, I have not been successful with using other published models included with pystrata. Here is an example layer, which the calculator cannot use:

model = [pystrata.site.Layer(
                pystrata.site.SoilType(name="Soil",
                                       unit_wt=18,
                                       mod_reduc="Seed & Idriss, Sand Mean",
                                       damping="Seed & Idriss, Sand Mean"),
                30, 400)]

I underlay this layer with rock:

    bedrock = pystrata.site.Layer(pystrata.site.SoilType("Rock", rho_br*9.8067, None, 1/2/Qs_br), 0, Vs_br)
    model.append(bedrock)

    # Create the profile object:
    ps_profile = pystrata.site.Profile(model)

Then attempt to calculate the EQL response using a time-history of my own. However, calculation fails producing the following errors:

  File "P:\Projects\Seismic\SHA\JPR_scenario\ReelfootFault\pySTRATA\bin\process_sta_trial.py", line 191, in calc_resp
    calc(ts, profile, profile.location("outcrop", index=-1))
  File "C:\Users\nvca223\Anaconda3\envs\pystrata\Lib\site-packages\pystrata\propagation.py", line 505, in __call__
    super().__call__(motion, profile, loc_input)
  File "C:\Users\nvca223\Anaconda3\envs\pystrata\Lib\site-packages\pystrata\propagation.py", line 288, in __call__
    self._calc_waves(motion.angular_freqs, profile)
  File "C:\Users\nvca223\Anaconda3\envs\pystrata\Lib\site-packages\pystrata\propagation.py", line 305, in _calc_waves
    wave_nums[i, :] = angular_freqs / l.comp_shear_vel
                                      ^^^^^^^^^^^^^^^^
  File "C:\Users\nvca223\Anaconda3\envs\pystrata\Lib\site-packages\pystrata\site.py", line 916, in comp_shear_vel
    return np.sqrt(self.comp_shear_mod / self.density)
                   ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\nvca223\Anaconda3\envs\pystrata\Lib\site-packages\pystrata\site.py", line 907, in comp_shear_mod
    comp_factor = np.sqrt(1 - 4 * damping**2) + 2j * damping
                                  ~~~~~~~^^~
TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'

It seems that pystrata is not obtaining nonlinear damping values from the "Seed & Idriss, Sand Mean" nonlinear curve as I expect.

Can you please describe what I am doing wrong or instruct me how to use the published nonlinear models?

Thanks!

Error in executing randomization of modulus reduction and damping ratio curves

Hello.
I have been using PYSTRATA for a long time and it worked very well. However, I just downloaded the latest version of PYSTRATA and Python both. During an equivalent linear analysis based on one of your examples, I executed the following command to implement the randomization of modulus reduction and damping ratio curves:

var_soiltypes = pystrata.variation.DarendeliVariation(-0.5)
count = 4
for geopsy_profile in iter_geopsy_profiles(fname):
for profile in pystrata.variation.iter_varied_profiles(
profile,
count,
var_thickness=None,
var_velocity=None,
var_soiltypes=var_soiltypes
):
calc(ts, profile, profile.location('outcrop', index=-1))
outputs(calc)

In earlier versions, it used to show only this message:
C:\Users\ADMIN\anaconda3\lib\site-packages\pystrata\site.py:741: RuntimeWarning: divide by zero encountered in divide
err = 100.0 * np.max((self.previous - self.value) / self.value)
C:\Users\ADMIN\anaconda3\lib\site-packages\pystrata\site.py:741: RuntimeWarning: invalid value encountered in divide
err = 100.0 * np.max((self.previous - self.value) / self.value)

But, it used to work well and provided the results properly.

However, with the latest version, It showed this message:
C:\Users\ADMIN\miniconda3\lib\site-packages\pystrata\site.py:804: RuntimeWarning: divide by zero encountered in divide
err = 100.0 * np.max((self.previous - self.value) / self.value)
C:\Users\ADMIN\miniconda3\lib\site-packages\pystrata\site.py:804: RuntimeWarning: invalid value encountered in divide
err = 100.0 * np.max((self.previous - self.value) / self.value)
C:\Users\ADMIN\miniconda3\lib\site-packages\pystrata\propagation.py:327: RuntimeWarning: overflow encountered in multiply
waves_a[i + 1, :] = 0.5 * waves_a[i] * (1 + cimped) * np.exp(
C:\Users\ADMIN\miniconda3\lib\site-packages\pystrata\propagation.py:327: RuntimeWarning: invalid value encountered in multiply
waves_a[i + 1, :] = 0.5 * waves_a[i] * (1 + cimped) * np.exp(
C:\Users\ADMIN\miniconda3\lib\site-packages\pystrata\propagation.py:329: RuntimeWarning: overflow encountered in multiply
) + 0.5 * waves_b[i] * (1 - cimped) * np.exp(-cterm)
C:\Users\ADMIN\miniconda3\lib\site-packages\pystrata\propagation.py:327: RuntimeWarning: invalid value encountered in add
waves_a[i + 1, :] = 0.5 * waves_a[i] * (1 + cimped) * np.exp(
C:\Users\ADMIN\miniconda3\lib\site-packages\pystrata\propagation.py:330: RuntimeWarning: overflow encountered in multiply
waves_b[i + 1, :] = 0.5 * waves_a[i] * (1 - cimped) * np.exp(
C:\Users\ADMIN\miniconda3\lib\site-packages\pystrata\propagation.py:330: RuntimeWarning: invalid value encountered in multiply
waves_b[i + 1, :] = 0.5 * waves_a[i] * (1 - cimped) * np.exp(
C:\Users\ADMIN\miniconda3\lib\site-packages\pystrata\propagation.py:332: RuntimeWarning: overflow encountered in multiply
) + 0.5 * waves_b[i] * (1 + cimped) * np.exp(-cterm)
C:\Users\ADMIN\miniconda3\lib\site-packages\pystrata\propagation.py:330: RuntimeWarning: invalid value encountered in add
waves_b[i + 1, :] = 0.5 * waves_a[i] * (1 - cimped) * np.exp(
C:\Users\ADMIN\miniconda3\lib\site-packages\pystrata\propagation.py:369: RuntimeWarning: overflow encountered in multiply
return 2 * self._waves_a[l.index] * np.exp(cterm)
C:\Users\ADMIN\miniconda3\lib\site-packages\pystrata\propagation.py:369: RuntimeWarning: invalid value encountered in multiply
return 2 * self._waves_a[l.index] * np.exp(cterm)
C:\Users\ADMIN\miniconda3\lib\site-packages\pystrata\propagation.py:455: RuntimeWarning: overflow encountered in multiply
denom = -(ang_freqs2) * self.wave_at_location(lin)
C:\Users\ADMIN\miniconda3\lib\site-packages\pystrata\propagation.py:455: RuntimeWarning: invalid value encountered in multiply
denom = -(ang_freqs
2) * self.wave_at_location(lin)
C:\Users\ADMIN\miniconda3\lib\site-packages\pystrata\propagation.py:461: RuntimeWarning: invalid value encountered in divide
tf[mask] = GRAVITY * numer[mask] / denom[mask]
C:\Users\ADMIN\miniconda3\lib\site-packages\pystrata\propagation.py:461: RuntimeWarning: overflow encountered in multiply
tf[mask] = GRAVITY * numer[mask] / denom[mask]
C:\Users\ADMIN\miniconda3\lib\site-packages\pystrata\propagation.py:309: RuntimeWarning: invalid value encountered in divide
wave_nums[i, :] = angular_freqs / l.comp_shear_vel
C:\Users\ADMIN\miniconda3\lib\site-packages\pystrata\propagation.py:329: RuntimeWarning: invalid value encountered in multiply
) + 0.5 * waves_b[i] * (1 - cimped) * np.exp(-cterm)
C:\Users\ADMIN\miniconda3\lib\site-packages\pystrata\propagation.py:332: RuntimeWarning: invalid value encountered in multiply
) + 0.5 * waves_b[i] * (1 + cimped) * np.exp(-cterm)
C:\Users\ADMIN\miniconda3\lib\site-packages\pystrata\propagation.py:451: RuntimeWarning: overflow encountered in multiply
self._waves_a[lout.index, :] * np.exp(cterm)
C:\Users\ADMIN\miniconda3\lib\site-packages\pystrata\propagation.py:451: RuntimeWarning: invalid value encountered in multiply
self._waves_a[lout.index, :] * np.exp(cterm)
C:\Users\ADMIN\miniconda3\lib\site-packages\pystrata\propagation.py:452: RuntimeWarning: invalid value encountered in multiply

  • self._waves_b[lout.index, :] * np.exp(-cterm)
    C:\Users\ADMIN\miniconda3\lib\site-packages\pystrata\propagation.py:448: RuntimeWarning: overflow encountered in multiply
    1j
    C:\Users\ADMIN\miniconda3\lib\site-packages\pystrata\propagation.py:461: RuntimeWarning: invalid value encountered in multiply
    tf[mask] = GRAVITY * numer[mask] / denom[mask]
    C:\Users\ADMIN\miniconda3\lib\site-packages\pystrata\propagation.py:327: RuntimeWarning: overflow encountered in exp
    waves_a[i + 1, :] = 0.5 * waves_a[i] * (1 + cimped) * np.exp(
    C:\Users\ADMIN\miniconda3\lib\site-packages\pystrata\propagation.py:330: RuntimeWarning: overflow encountered in exp
    waves_b[i + 1, :] = 0.5 * waves_a[i] * (1 - cimped) * np.exp(
    C:\Users\ADMIN\miniconda3\lib\site-packages\pystrata\propagation.py:448: RuntimeWarning: invalid value encountered in multiply
    1j
    C:\Users\ADMIN\miniconda3\lib\site-packages\pystrata\propagation.py:451: RuntimeWarning: invalid value encountered in subtract
    self._waves_a[lout.index, :] * np.exp(cterm)
    C:\Users\ADMIN\miniconda3\lib\site-packages\pystrata\propagation.py:451: RuntimeWarning: overflow encountered in subtract
    self._waves_a[lout.index, :] * np.exp(cterm)
    C:\Users\ADMIN\miniconda3\lib\site-packages\pystrata\propagation.py:309: RuntimeWarning: divide by zero encountered in divide
    wave_nums[i, :] = angular_freqs / l.comp_shear_vel
    C:\Users\ADMIN\miniconda3\lib\site-packages\pystrata\propagation.py:362: RuntimeWarning: invalid value encountered in multiply
    cterm = 1j * self._wave_nums[l.index] * l.depth_within
    C:\Users\ADMIN\miniconda3\lib\site-packages\pystrata\site.py:804: RuntimeWarning: divide by zero encountered in double_scalars
    err = 100.0 * np.max((self.previous - self.value) / self.value)
    C:\Users\ADMIN\miniconda3\lib\site-packages\pystrata\propagation.py:387: RuntimeWarning: invalid value encountered in divide
    tf = self.wave_at_location(lout) / self.wave_at_location(lin)
    C:\Users\ADMIN\miniconda3\lib\site-packages\pystrata\propagation.py:561: RuntimeWarning: divide by zero encountered in double_scalars
    l.strain = self._motion.pgv / l.initial_shear_vel
    C:\Users\ADMIN\miniconda3\lib\site-packages\pystrata\site.py:804: RuntimeWarning: invalid value encountered in double_scalars
    err = 100.0 * np.max((self.previous - self.value) / self.value)

After that, it generated results, but in the output, the majority of the values are shown as 'NaN' and therefore, in the plots also, very few output curves are shown (Figure attached(Previous version and current)). I request you to kindly let me know how to rectify this error.

PreviousVersion
LatestVersion

problems with pystrata.site._load_published_curves()

Hi, I am working through some of the examples and came across a problem with example 15. Here's what I ran:

import pystrata

pystrata.site._load_published_curves()

And this is what was returned:

Traceback (most recent call last):
  File "P:\Projects\Seismic\SHA\JPR_scenario\ReelfootFault\pySTRATA\bin\nonlinear_work.py", line 3, in <module>
    pystrata.site._load_published_curves()
  File "C:\Users\nvca223\Anaconda3\envs\pystrata\Lib\site-packages\pystrata\site.py", line 56, in _load_published_curves
    models = tomli.load(fp)["models"]
             ^^^^^^^^^^^^^^
  File "C:\Users\nvca223\Anaconda3\envs\pystrata\Lib\site-packages\tomli\_parser.py", line 66, in load
    return loads(s, parse_float=parse_float)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\nvca223\Anaconda3\envs\pystrata\Lib\site-packages\tomli\_parser.py", line 116, in loads
    raise suffixed_err(src, pos, "Invalid statement")
tomli.TOMLDecodeError: Invalid statement (at line 1, column 1)

The published_curves.toml file was not apparently included in my original download, so I downloaded it from github and installed it at ...\Anaconda3\envs\pystrata\Lib\site-packages\pystrata\data. I had to create the "data" folder shown in that path.

I would appreciate any help sorting out this issue.

No module named 'pyrvt'

Hello, I just installled pystrata and when running the first example as a jupyter threw teh following error, suggesting the pyrvt module is missing. I installed all the dependencies listed (cmake, qt, gsl, qwt, and fftw). How can I fix this?

`import matplotlib.pyplot as plt
import numpy as np

import pystrata

%matplotlib inline


ModuleNotFoundError Traceback (most recent call last)
Cell In[7], line 4
1 import matplotlib.pyplot as plt
2 import numpy as np
----> 4 import pystrata
6 get_ipython().run_line_magic('matplotlib', 'inline')

File ~\Anaconda3\envs\pystrata\Lib\site-packages\pystrata_init_.py:23
1 # -- coding: utf-8 --
2 # The MIT License (MIT)
3 #
(...)
21 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 # SOFTWARE.
---> 23 from . import motion
24 from . import output
25 from . import propagation

File ~\Anaconda3\envs\pystrata\Lib\site-packages\pystrata\motion.py:27
24 import re
26 import numpy as np
---> 27 import pyrvt
28 from scipy.constants import g as GRAVITY
30 # Gravity in m/sec²

ModuleNotFoundError: No module named 'pyrvt'`

The maximum shear strain profile estimated in MaxStrainProfile is returning Array of strain values for a layer

Dear sir,
While running a site response analysis, I came across the following problem.

Error:
The maximum shear strain profile estimated in MaxStrainProfile class for a layer is returning Array of strain values.

Possible reason:
Line 437, output.py:
values = [0] + [l.strain for l in calc.profile[:-1]]

The above line can be modified as
values = [0] + [l.strain_max for l in calc.profile[:-1]]
to obtain correct results..

Kindly confirm whether the above fix is ok...

Issue with cyko package not building on install

I am trying to install pysra from requirements.txt it doesn't build unless I first manually install Cython.

See error message below:

Collecting cyko (from pySRA->-r requirements.txt (line 8))
Downloading https://files.pythonhosted.org/packages/06/10/7401c797e805c04ddce76aec75ee100c4894fe97b3c5af078f678a4fdcd5/cyko-0.2.5.2.tar.gz (54kB)
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-install-a64yu20q/cyko/setup.py", line 3, in
from Cython.Build import cythonize
ModuleNotFoundError: No module named 'Cython'

Maximum recursion depth exceeded while calling a Python object

I noticed this error occurring in python 3.7 but not in python 3.6. The error occurs when all the soil layers are added (i.e., when I execute this: "pysra.site.Profile(layers)"). Below is some information on where this error occurs.

File "/home1/04482/marafi/anaconda3/lib/python3.7/site-packages/pysra/site.py", line 833, in init
self.update_layers()
File "/home1/04482/marafi/anaconda3/lib/python3.7/site-packages/pysra/site.py", line 845, in update_layers
for layer in self[start_layer:]:
File "/home1/04482/marafi/anaconda3/lib/python3.7/collections/init.py", line 1096, in getitem
return self.class(self.data[i])
RecursionError: maximum recursion depth exceeded while calling a Python object
self.update_layers()

Let me know if you need more information. If you are unable to recreate this error, try using a large number of soil layers (>100).

Pip installer is broken

    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-owr_sa2y/pysra/setup.py", line 9, in <module>
        with open('HISTORY.md') as fp:
    FileNotFoundError: [Errno 2] No such file or directory: 'HISTORY.md'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.