Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Simple python script to compute stress tensor for nucleation #1095

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jwjeremy
Copy link
Contributor

@AliceGabriel
A simple Python script to compute stress tensor (potentially useful for nucleation stress) given fault geometry and stress level

A simple Python script to compute stress tensor (potentially useful for nucleation stress) given fault geometry and stress level
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 13.79%. Comparing base (b736ca1) to head (c48f3af).

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1095   +/-   ##
=======================================
  Coverage   13.79%   13.79%           
=======================================
  Files         268      268           
  Lines       15011    15011           
=======================================
  Hits         2071     2071           
  Misses      12940    12940           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jwjeremy jwjeremy changed the title Create get_nuc_stress_tensor.py Simple python script to compute stress tensor for nucleation Apr 15, 2024
Copy link
Contributor

@Thomas-Ulrich Thomas-Ulrich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this PR (and for noticing what was the problem with the nucleation stress in the Kaikoura and Palu setups).
But is it not simpler to use Tnuc_s and Tnuc_d?

!Switch
[Tnuc_n,Tnuc_s,Tnuc_d]: !LuaMap
  returns: [Tnuc_n,Tnuc_s,Tnuc_d]
  function: |
     function f (x)
      ShapeNucleation = 0.0
      xh =  -3581
      yh = -29146
      zh = -10000
      -- rake in SeisSol convention
      rake = 30 * math.pi/180
      r_crit = 1500.0
      r = math.sqrt((x["x"]-xh)^2 + (x["y"]-yh)^2 + (x["z"]-zh)^2 )
      if (r < r_crit) then
        peakNucleationStress =  math.exp(r^2/(r^2-r_crit^2))*20*math.pow(10,6)
      end
      return {
        Tnuc_n = 0.0,
        Tnuc_d =  peakNucleationStress*sin(rake),
        Tnuc_s = peakNucleationStress*cos(rake)
      }
      end

(or you can replace 20 by R_nuc*(fs - fd)Pn0 + fdPn0)

import argparse
from argparse import RawTextHelpFormatter

def fnomral(dip,strike):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

@@ -0,0 +1,118 @@
### compute nucleation stress tensor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add
#!/usr/bin/env python3
and chmod +x on the script


parser = argparse.ArgumentParser(
description="Compute nucleation stress tensor given fault geometry and stress level",
epilog="Examples: \npython get_nuc_stresstensor.py --geometry 9.58 202.27 90 --Traction -18.82 --yaml \npython get_nuc_stresstensor.py --geometry 9.58 202.27 90 --R_nuc 1.1 0.7 0.1 33.6",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove python (if you agree making the file executable)

dip, strike, rake = args.geometry

### compute traction if needed
if args.R_nuc is None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if not args.R_nuc
(try flake8 on your script)

T0 = R_nuc*(fs - fd)*Pn0 + fd*Pn0

Td0 = T0 * np.sin(np.deg2rad(rake))
Ts0 = T0 * np.cos(np.deg2rad(rake))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that rake must be in seissol convention.
(e.g. adapted from Slipnear: "rake" (degrees) is the slip angle (not Aki's convention, e.g. rake=+45 means right-lateral-reverse movement).

T0 = args.Traction
else:
R_nuc, fs, fd, Pn0 = args.R_nuc
T0 = R_nuc*(fs - fd)*Pn0 + fd*Pn0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pn0 should be positive?

returns: [nuc_xx, nuc_yy, nuc_zz, nuc_xy, nuc_yz, nuc_xz]
function: |
function f (x)
xc = -18440.7
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe leave empty?
same for xc, yc, r_crit?

end

return {{
nuc_xx = ShapeNucleation * {S_cartesian[0,0]:.3f} * 1000000;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put the 1000000 in ShapeNucleation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants