santex.anisotropy package#

Submodules#

santex.anisotropy.anisotropy module#

class santex.anisotropy.anisotropy.Anisotropy(stiffness_matrix, density)#

Bases: object

A class to represent anisotropic material properties.

Attributes:

cijkl (Optional[numpy.ndarray]): Stiffness tensor in Voigt notation.

It is converted from the input stiffness matrix using the voigt_to_tensor method. If stiffness_matrix is None, cijkl remains None. Units should be consistent between the stiffness matrix and density, either in SI or CGS.

rho (Optional[float]): Density of the material.

If density is None, rho remains None.

Parameters:

stiffness_matrix (Optional[numpy.ndarray]): A 6x6 matrix representing the stiffness tensor in Voigt notation. density (Optional[float]): The density of the material.

Methods:

__init__(stiffness_matrix, density):

Initializes the Anisotropy object with the given stiffness_matrix and density. If either stiffness_matrix or density is None, cijkl and rho remain None.

Example:

>>> import numpy as np
>>> stiffness_matrix = np.array([[198.96, 73.595, 68.185, 0., 9.735, 0.],
>>>                              [73.595, 155.94, 62.23, 0., 6.295, 0.],
>>>                              [68.185, 62.23, 225.99, 0., 33.85, 0.],
>>>                              [0., 0., 0., 65.66, 0., 6.415],
>>>                              [9.735, 6.295, 33.85, 0., 60.23, 0.],
>>>                              [0., 0., 0., 6.415, 0., 65.18]]) * 10**9
>>> density = 3.5  # density in g/cm³ or consistent units
>>> anisotropy = Anisotropy(stiffness_matrix, density)
>>> print(anisotropy.cijkl)
>>> print(anisotropy.rho)
anisotropy_values(stiffness_matrix=None, density=None, method=None, return_values=None)#

Calculates various anisotropy values based on the velocities calculated from the given stiffness matrix and density.

Parameters:
stiffness_matrix (list or None): The stiffness matrix representing the material’s anisotropic properties.

If None, the current object’s stiffness matrix is used.

density (float or None): The density of the material. If None, the current object’s density is used.

method (str or None): The method to use for calculating anisotropy values. Options include ‘array’ for batch

processing of multiple anisotropy objects.

return_values (str or None): The specific anisotropy value to return. Options: ‘maxvp’, ‘minvp’, ‘maxvs1’,

‘minvs1’, ‘maxvs2’, ‘minvs2’, ‘max_vs_anisotropy_percent’, ‘min_vs_anisotropy_percent’, ‘p_wave_anisotropy_percent’, ‘s1_wave_anisotropy_percent’, ‘s2_wave_anisotropy_percent’, ‘maxdvs’, ‘AVpVs1’, or None (default) to print all values.

Returns:

float or dict: If return_values is specified, returns the corresponding anisotropy value. If None, returns a dictionary containing all calculated anisotropy values.

Raises:

ValueError: If an error occurs during the calculation, such as invalid input values.

Notes:
  • If method=’array’, an array of Anisotropy objects can be provided for batch calculation.

  • The calculated anisotropy values include both P-wave and S-wave anisotropy percentages.

christoffel_tensor(n)#

Calculates the Christoffel tensor given a direction vector n.

Parameters:

n (numpy.ndarray): The direction vector for which the Christoffel tensor is calculated.

Returns:

numpy.ndarray: The Christoffel tensor Tik for the given direction vector n.

Raises:

ValueError: If an error occurs during the calculation.

Example direction:

n = np.array([1, 0, 0])

get_compliance()#
hill_velocity()#
phase_velocity()#

Calculates the phase velocities (P-wave velocity, S1-wave velocity, and S2-wave velocity) for different directions using the Christoffel tensor and wave properties.

Returns:

tuple: A tuple containing the phase velocities (vp for P-wave, vs1 for S1-wave, and vs2 for S2-wave).

Raises:

ValueError: If an error occurs during the calculation.

plot(colormap='RdBu', step=180, savefig=False, figname=None, dpi=300, save_format='svg', vmin_vmax=None, show_box=False, show_contour_labels=False)#

Plots various anisotropic maps based on the Christoffel tensor.

Parameters:

colormap (str): The colormap to use for plotting. Default is “RdBu_r”. step (int): The step size for theta and phi values. Default is 180. savefig (bool): Whether to save the plot as an image. Default is False. figname (str or None): The filename to save the plot. Required if savefig is True. dpi (int): The resolution of the saved image. Default is 300. save_format (str): The format to save the image. Default is ‘svg’. vmin_vmax (dict or None): Dictionary containing vmin and vmax values for each plot.

Expected keys: ‘vpvs1’, ‘vp’, ‘vs1’, ‘vs2’, ‘vpvs2’, ‘avs’ Each value should be a tuple (vmin, vmax) or None for default. Example: {‘vpvs1’: (1.5, 2.0), ‘vp’: None, ‘vs1’: (3000, 4000)}

show_box (bool): Whether to show the box (axes spines) around each subplot. Default is True. show_contour_labels (bool): Whether to show contour value labels on contour lines. Default is True.

Raises:

ValueError: If an error occurs during the plotting process.

Notes:
  • This method generates a 2x3 grid of subplots, each representing different anisotropic maps based on the Christoffel tensor.

  • The colormap, step size, and other parameters can be customized.

  • vmin and vmax can be set individually for each subplot using the vmin_vmax dictionary.

Example Usage:

# With custom vmin/vmax for specific plots vmin_vmax_dict = {

‘vpvs1’: (1.5, 2.2), ‘vp’: (5000, 7000), ‘vs1’: None, # Use default ‘vs2’: (3000, 4500), ‘vpvs2’: (1.8, 2.5), ‘avs’: (-10, 10)

} anisotropy.plot(colormap=”viridis”, step=120, savefig=True,

figname=”anisotropy_plot”, dpi=600, vmin_vmax=vmin_vmax_dict)

# Without boxes around subplots anisotropy.plot(show_box=False)

# Without contour labels anisotropy.plot(show_contour_labels=False)

# Clean stereonet plot without boxes or contour labels anisotropy.plot(show_box=False, show_contour_labels=False)

plot_velocities(pressure_range, temperature_range, return_type, is_ebsd=False, phase=None, grid=[5, 5], filename=None, *args)#

Plots velocities based on specified ranges and return types.

Parameters:

pressure_range (tuple): The range of pressures for which velocities will be plotted. Example: [2, 4]. temperature_range (tuple): The range of temperatures for which velocities will be plotted. Example: [1000, 2000]. return_type (str): The type of velocity to plot. Options: ‘maxvp’, ‘minvp’, ‘maxvs1’, ‘minvs1’, ‘maxvs2’, ‘minvs2’. is_ebsd (bool): Whether the data comes from electron backscatter diffraction (EBSD). Default is False. phase (str or None): The phase of the material. Example: phase=’Forsterite’. grid (list): The grid dimensions for the plot. Default is [5, 5]. filename (str or None): The filename of the EBSD data. Required if is_ebsd is True. *args: Additional arguments for plot customization.

Raises:

ValueError: If required parameters are not provided or if an error occurs during plotting.

Notes:
  • If is_ebsd is True, phase and filename must be provided.

  • The plot type and appearance can be customized using *args.

Example:
>>> anisotropy.plot_velocities((0, 100), (500, 1000), 'maxvp', is_ebsd=True, phase='phase1', filename='velocity_plot.png', 'ro-')
plotly()#

Generates a Plotly figure to visualize material properties based on calculations using Christoffel and wave tensors.

This method creates a Plotly figure with subplots for various properties such as VP/VS1, VP, VS1, VS2, AVpVs1, and AVpVs2. The figure is generated by iterating over specified ranges of angles and calculating properties like wave moduli, VP, VS1, VS2, VP/VS1 ratios, and AVpVs1/AVpVs2 ratios. The resulting data points are plotted on scatter plots with a color scale representing different property values.

Raises:

ValueError: If an error occurs during the plotting process.

Notes:
  • Requires the existence of the christoffel_tensor and wave_property methods in the class instance to calculate material properties.

Example Usage:

plotter = anisotropy_instance.plotly()

plotter_vp(density, voigt_stiffness)#

Plots the Vp based on density and Voigt stiffness.

Parameters:

density (float): The density of the material. voigt_stiffness (float): The Voigt stiffness of the material.

plotter_vs1(density, voigt_stiffness)#

Plots the Vs1 based on density and Voigt stiffness.

Parameters:

density (float): The density of the material. voigt_stiffness (float): The Voigt stiffness of the material.

plotter_vs2(density, voigt_stiffness)#

Plots the Vs2 based on density and Voigt stiffness.

Parameters:

density (float): The density of the material. voigt_stiffness (float): The Voigt stiffness of the material.

plotter_vs_splitting(density, voigt_stiffness)#

Plots the Vs splitting based on density and Voigt stiffness.

Parameters:

density (float): The density of the material. voigt_stiffness (float): The Voigt stiffness of the material.

reuss_velocity()#
velocities()#
voigt_velocity()#
wave_property(tik)#

Calculates the wave properties (wave moduli and polarization directions) given the Christoffel tensor Tik.

Parameters:

tik (numpy.ndarray): The Christoffel tensor Tik for which wave properties are calculated.

Returns:

tuple: A tuple containing the wave moduli and polarization directions.

Raises:

ValueError: If an error occurs during the calculation.

santex.anisotropy.map module#

santex.anisotropy.melt module#

santex.anisotropy.melt.calc_melt_density(weight_per, pressure, temperature)#

Calculates the density and component density of a melt based on its composition.

Parameters:
weight_per (list or dict): List or dictionary representing the weight percentage of various oxides in the melt.

If a dictionary is provided, it should have oxide names as keys and corresponding weight percentages as values.

pressure (float): Pressure of the melt in bars. temperature (float): Temperature of the melt in Kelvin.

Returns:

density (float): Density of the melt. component_density (array): Component-wise density of the melt.

Example Usage: oxide = [‘sio2’, ‘tio2’, ‘al2o3’, ‘fe2o3’, ‘feo’, ‘mgo’, ‘cao’, ‘na2o’, ‘k2o’, ‘h2o’] weight_per = [40, 1.84, 13.7, 2.7, 9.57, 6.67, 11.5, 2.68, 0.25, 10] or weight_per can be a dictionary like {‘sio2’: 40, ‘tio2’: 1.84, ‘feo’: 9.57, ‘mgo’: 6.67, ‘cao’: 11.5, ‘na2o’: 2.68, ‘k2o’: 0.25, ‘h2o’: 10}

santex.anisotropy.melt.calc_melt_density_from_excel(input_file, output_file)#

Calculates melt densities for samples listed in an input Excel file and saves the results to an output Excel file.

Parameters:

input_file (str): Path to the input Excel file containing sample data. output_file (str): Path to save the output Excel file with calculated melt densities.

Sample excel file:

Sample Name Pressure (bars) Temperature (K) SiO2 TiO2 Al2O3 Fe2O3 FeO MgO CaO Na2O K2O H2O sample_wir_01 500 1273 45.5 2.1 15.8 3.4 8.2 4.9 10.2 3.3 0.6 5.5 sample_wir_02 500 1273 49.7 1.9 14.3 2.8 7 .1 5.6 9.8 4.1 0.7 4.0

santex.anisotropy.melt.modal_rock(rock, fraction, pressure, temperature, melt=0, weight_per=[])#

Calculates the average elastic constants and density of a rock mixture.

Parameters:

rock (list): An array of mineral names constituting the rock mixture. fraction (list): An array corresponding to the fractional composition of each mineral in the rock. pressure (float): Pressure of the rock mixture in GPa. temperature (float): Temperature of the rock mixture in Kelvin. melt (float, optional): Fraction of melt in the rock mixture. Set to a non-zero value if there is a melt component. Default is 0. weight_per (list, optional): Weight percentage of oxides in the melt component, required if melt is non-zero. Default is [].

Returns:

cij_average (array): Average elastic constants of the rock mixture. rho_average (float): Average density of the rock mixture.

Example Usage:

Rock is an array of minerals and fraction is another array corresponding to the particular phase. eg. rock = [“Forsterite”, “Diopside”, “Enstatite”], fraction = [0.2, 0.5, 0.3]

santex.anisotropy.modalAnisotropy module#

santex.anisotropy.modalAnisotropy.modal_anisotropy(material, fraction, pressure, temperature)#

santex.anisotropy.plot_seismic_velocity module#

santex.anisotropy.plot_seismic_velocity.phase_velocity(cijkl, rho)#

Calculate phase velocities for various propagation directions.

Parameters: - cijkl (array): The fourth-rank stiffness tensor for the material. - rho (float): Density of the material.

Returns: - tuple: Tuples containing phase velocities for P-wave (vp), S-wave with higher velocity (vs1), and S-wave with lower velocity (vs2).

santex.anisotropy.plot_seismic_velocity.plot_vp_2d(cijkl, rho, save_plot=False, filename=None, dpi=300, cmap='RdBu')#

Plot phase velocities in a 2D stereographic projection.

Parameters: - cijkl (array): The fourth-rank stiffness tensor for the material. - rho (float): Density of the material. - save_plot (bool): Whether to save the plot or not. Default is False. - filename (str): Name of the file to save the plot. Required if save_plot is True. - dpi (int): Dots per inch for saving the plot. Default is 300. - cmap (str or Colormap): The colormap to be used for the scatter plot. Default is ‘RdBu’.

Returns: - None

santex.anisotropy.plot_vel_grid module#

santex.anisotropy.plot_vel_grid.plot_velocity_grid(pressure_range, temperature_range, return_type, is_ebsd=False, phase=None, grid=[5, 5], filename=None, fig_name=None, save_plot=False, dpi=300, *args)#

santex.anisotropy.utils module#

santex.anisotropy.utils.christoffel_tensor(cijkl, n)#
santex.anisotropy.utils.wave_property(tik)#

santex.anisotropy.vtkplotter module#

class santex.anisotropy.vtkplotter.Plotter#

Bases: object

A class for plotting seismic wave velocities in 3D using VTK.

Attributes: - None

classmethod plot_vp(c, rho)#

Plot the P-wave velocities (vp) in 3D using VTK.

This method calculates and visualizes the P-wave velocities (vp) for a given fourth-rank stiffness tensor (c) and material density (rho) using the Visualization Toolkit (VTK).

Parameters: - c (array): The fourth-rank stiffness tensor in Voigt notation. - rho (float): Density of the material.

Returns: - None

Usage Example: >>> c = np.array([[323.70, 66.40, 71.60, 0.000, 0.000, 0.000], … [66.40, 197.60, 75.60, 0.000, 0.000, 0.000], … [71.60, 75.60, 235.10, 0.000, 0.000, 0.000], … [0.000, 0.000, 0.000, 64.62, 0.000, 0.000], … [0.000, 0.000, 0.000, 0.000, 78.05, 0.000], … [0.000, 0.000, 0.000, 0.000, 0.000, 79.04]]) * 1e9 >>> Plotter.plot_vp(c, 3310)

classmethod plot_vs1(c, rho)#

Plot the S-wave velocities with higher velocity (vs1) in 3D using VTK.

Parameters: - c (array): The fourth-rank stiffness tensor in Voigt notation. - rho (float): Density of the material.

Returns: - None

classmethod plot_vs_splitting(c, rho)#

Plot the difference between S-wave velocities (vs1 - vs2) in 3D using VTK.

Parameters: - c (array): The fourth-rank stiffness tensor in Voigt notation. - rho (float): Density of the material.

Returns: - None

Module contents#