Skip to main content

RUSpectroscopy_tools

  • A tool to solve the inverse problem in RUS (Resonant Ultrasound Spectroscopy) of cubic materials using Machine Learning.

  • Model used for the tool available at HuggingFace.

  • Solves forward problem also using all your CPU cores (written in C). Working on support for GPU (only AMD HIP/ROCm. I REFUSE TO DO A NVIDIA CUDA VERSION)

Installation

pip3 install ruspectroscopy-tools

Forward

A C extension module for getting the resonance frequencies given the estic constants, the dimension and the shpe of the sample.

Inverse

Uses a neural network model to get the constants of a cubic (more complex crystal structures coming soon) solid (parallelepiped shape, other shapes comming soon) given the dimensions and 20 resonence frequencies. No rotations supported yet.

Authors

If the tool or any of the code is useful to you please cite:

Cubillos Muñoz, J. (2025). A machine learning approach to the inverse problem in resonant ultrasound spectroscopy of cubic and isotropic solids. Universidad de los Andes. Available at: Repositorio Seneca Uniandes

Inverse problem usage

Getting the elastic constants from the resonence frequencies

from rusmodules import inverse

inverse_data = inverse.inverse_problem_default(m, omega, dimensions)

Where:

  • m (float) Is the mass of the sample

  • omega (np.array) Resonance omegas (frequencies in radians NOT in Hz)

  • dimensions (np.array) (3,) shape array containing the dimensions of the sample: [Lx, Ly, Lz]

Inverse Problem usage example

Here we predict the elstic constants of a Parallelepiped sample with mass:

$ m = 0.1254 $,

dimensions:

$L_x = 0.30529, L_y = 0.20353, L_z = 0.25334$,

and the following frequencies (in radians):

omega = [1.50926584, 1.65836575, 1.75117538, 2.01686081, 2.06256988,
       2.19098222, 2.34152748, 2.8107501 , 2.89962897, 2.90586193,
       2.98053128, 3.01687171, 3.04870302, 3.0491472 , 3.11933117,
       3.54120588, 3.65460307, 3.69446139, 3.75998903, 3.78313654] 

using the following code:

m = 0.1254 #g
dimensions = np.array([0.30529, 0.20353, 0.25334]) #cm
inverse_data_default = inverse.inverse_problem_default(m,  omega, dimensions)

This returns a dictionary that looks like this:

{
       'constants': {
              'C00': np.float64(1.30054267050163), 
              'C01': np.float64(1.1006489848946313), 
              'C33': np.float64(0.8854417640647991)
       }, 
       'MAE': np.float64(0.02978091807048346), 
       'frequencies': array([1.52869445, 1.67824553, 1.77995932, 
        2.04882852, 2.09089336, 2.226468  , 2.35439033, 2.75882012, 
        2.85318217, 2.93387907, 3.00654262, 3.0245675 , 3.04501862, 
        3.05716655, 3.06015376, 3.5581114 , 3.56426523, 3.65992212, 
        3.69013139, 3.75229874])
}

The returned frequencies in radians (NOT Hz) are the ones to compare to the original frequencies. MAE is the mean absolute error between the experimental frequencies and the computed frequencies from the predicted constants.

Forward Problem Usage

Getting the resonance frequencies from the elastic constants

from rusmodules import eigenvals 

frequencies = eigenvals.forward_problem(m, C, dimensions, N, shape)

Where:

  • m (float) Is the mass of the sample

  • N (int) represents the maximim grade of the polynomials of the basis functions (default: 6)

  • C (np.array) 6x6 matrix with the elastic constants

  • dimensions (np.array>) (3,) shape array containing the dimensions of the sample: [Lx, Ly, Lz]

  • shape (str) Currently supports "Parallelepiped", "Cylinder" and "Ellipsoid"

Inverse Problem with cusom models

You can also download another model (for now we've only uploaded one) from huggingFace and store it in your preferred location i.e: ./models/:

mkdir models
wget https://huggingface.co/Cubos/InverseRUS/resolve/main/cubico_L4.keras

To use the model trained in this work you can follow this example. The stats of the training data of the model must match their corresponding model. For example to get the statistics of cubico_L4, we can download the from: repo/notebooks/models/cubico_L4.csv.

import os
import numpy as np
from rusmodules import inverse
import torch
os.environ["KERAS_BACKEND"] = "torch"
import keras
import pandas as pd

m = 0.1254 #g
path_model = "models/cubico_L4.keras"
stats_model = pd.read_csv("https://raw.githubusercontent.com/cubos-d/RUSpectroscopy_Tools/refs/heads/main/notebooks/models/cubico_L4_stats.csv")
stats_model = stats_model.set_index("Unnamed: 0")
dic_stats = dict(map(lambda x: (x, dict(map(lambda y: (y, stats_model[y][x]),stats_model.keys()))), ["mean", "std"]))
model = keras.models.load_model(path_model)
omega = [1.50926584, 1.65836575, 1.75117538, 2.01686081, 2.06256988,
       2.19098222, 2.34152748, 2.8107501 , 2.89962897, 2.90586193,
       2.98053128, 3.01687171, 3.04870302, 3.0491472 , 3.11933117,
       3.54120588, 3.65460307, 3.69446139, 3.75998903, 3.78313654] #This must be a list of 20 values all in units of radians
dimensions = np.array([0.30529, 0.20353, 0.25334]) #cm
model_data = {**dic_stats, "model": model}
inverse_data = inverse.inverse_problem(m, omega, dimensions, model_data)

The machine learning models can be found in hugging face: Cubos/HuggingFace and the statistics of each model can be found in Means and Averages of the feeding.

Metadata

Release files for ruspectroscopy-tools 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ruspectroscopy-tools 0.0.4
File Size Uploaded Provenance Actions
ruspectroscopy_tools-0.0.4.tar.gz 18.9 kB With provenance Details for ruspectroscopy_tools-0.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ruspectroscopy-tools 0.0.4
File Interpreter ABI Platform Actions
ruspectroscopy_tools-0.0.4-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.28+ x86-64, Linux glibc 2.17+ x86-64 Details for ruspectroscopy_tools-0.0.4-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Total release size: 172.7 kB

Release files / ruspectroscopy_tools-0.0.4.tar.gz

Download URL ruspectroscopy_tools-0.0.4.tar.gz
Size 18.9 kB
Tags Source
SHA-256 checksum
How to use checksums
41f8d07b6f365fff1827a4455f815ee06d56f22481d8c5d9ca0f8799f3a2c278
BLAKE2b-256 checksum
How to use checksums
8630784508551e0f98cc8905d14262fb1fd3651ba724b99f3976ee8d795951f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Release files / ruspectroscopy_tools-0.0.4-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL ruspectroscopy_tools-0.0.4-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 153.8 kB
Tags CPython 3.14 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
40b9f2306ae174deef78366c55df2797441028a85ce22a8f372f8243cbce2d27
BLAKE2b-256 checksum
How to use checksums
14870cfd4b116f396946c9f783b60d9f98e59b730a9f39d2fd3f09fc9b31a548
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Security for ruspectroscopy-tools 0.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ruspectroscopy_tools-0.0.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page