Skip to main content

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

Project description

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

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

  • Alejandro Cubillos - mail1 mail2
  • Julián Rincón

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

Installation

pip3 install ruspectroscopy-tools

Import

from rusmodules import rus

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 usage

Getting the elastic constants from the resonence frequencies

from rusmodules import inverse

inverse_data = inverse.inverse_problem(m, omega, dimensions, model_data)

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]

  • model_data (dict) A dictionary containing the machine learning model and statistics of the training data that was used to generate the model.

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.

Inverse Problem example usage

To use the model you must download it from huggingFace and store it in you 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 can be found at 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 dictionary that returns inverse_problem (inverse_data) function 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ruspectroscopy_tools-0.0.3.tar.gz (17.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

ruspectroscopy_tools-0.0.3-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (148.9 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

ruspectroscopy_tools-0.0.3-cp313-cp313-musllinux_1_2_x86_64.whl (181.5 kB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

ruspectroscopy_tools-0.0.3-cp313-cp313-musllinux_1_2_i686.whl (189.9 kB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ i686

ruspectroscopy_tools-0.0.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (106.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

ruspectroscopy_tools-0.0.3-cp313-cp313-manylinux_2_17_i686.manylinux2014_i686.whl (107.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ i686

ruspectroscopy_tools-0.0.3-cp312-cp312-musllinux_1_2_x86_64.whl (181.5 kB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

ruspectroscopy_tools-0.0.3-cp312-cp312-musllinux_1_2_i686.whl (189.9 kB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ i686

ruspectroscopy_tools-0.0.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (106.4 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

ruspectroscopy_tools-0.0.3-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl (107.6 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ i686

File details

Details for the file ruspectroscopy_tools-0.0.3.tar.gz.

File metadata

  • Download URL: ruspectroscopy_tools-0.0.3.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ruspectroscopy_tools-0.0.3.tar.gz
Algorithm Hash digest
SHA256 a4fa28a929a5e4a43e3e78f7162d39b20a7a8f9721b5cd28419d2a6614e7c4f7
MD5 7fdb5e842b61ea0d1a8f787c02fd3324
BLAKE2b-256 51a614e819ceef1a23b1bb3fe20165be633079d83c4cfdf35cf5f4d5cf0fe0c4

See more details on using hashes here.

Provenance

The following attestation bundles were made for ruspectroscopy_tools-0.0.3.tar.gz:

Publisher: pypi-publish.yml on cubos-d/RUSpectroscopy_Tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ruspectroscopy_tools-0.0.3-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ruspectroscopy_tools-0.0.3-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7e222e6fe961a80319aaf308ababb0888cc414e1cf67e794c735f597ae44e150
MD5 acd6909f4da879faa4d4a29bbe37d120
BLAKE2b-256 05e19ae74cbc92171396308985a33c1af4f5da9bf7561d9a3e07593d90f659d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for ruspectroscopy_tools-0.0.3-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: pypi-publish.yml on cubos-d/RUSpectroscopy_Tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ruspectroscopy_tools-0.0.3-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for ruspectroscopy_tools-0.0.3-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 5c8d48de70f76c41d2381d76b86d323067108b7dd799a48e368ffb7721b42a61
MD5 520036913ad87da0776334ff324755b0
BLAKE2b-256 64428d4120d44751c31b94608769daca949cd8abfd714547aa04542bc5d165a8

See more details on using hashes here.

Provenance

The following attestation bundles were made for ruspectroscopy_tools-0.0.3-cp313-cp313-musllinux_1_2_x86_64.whl:

Publisher: pypi-publish.yml on cubos-d/RUSpectroscopy_Tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ruspectroscopy_tools-0.0.3-cp313-cp313-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for ruspectroscopy_tools-0.0.3-cp313-cp313-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 1d9123bc9445fb336ec82a504a46b3b8dc99436dc4305fde1f1127c3015ad70a
MD5 268b00599082a485b423060db45b42e8
BLAKE2b-256 fba21cff65156f08ad0e407c0293f7be72d3c55bc41e6ab9ff1670c23e3e83b3

See more details on using hashes here.

Provenance

The following attestation bundles were made for ruspectroscopy_tools-0.0.3-cp313-cp313-musllinux_1_2_i686.whl:

Publisher: pypi-publish.yml on cubos-d/RUSpectroscopy_Tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ruspectroscopy_tools-0.0.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ruspectroscopy_tools-0.0.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 714ed093517ec1c625633b33fa3a46e908010d9361c6a88f2d8d7fbb0e934a8c
MD5 65413bc826f949ef2f05318c24cb9f1d
BLAKE2b-256 3e0840e03c884cf437dafe5b1d978a663f2fb4f4ac861a390fefe877b636b7d7

See more details on using hashes here.

Provenance

The following attestation bundles were made for ruspectroscopy_tools-0.0.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: pypi-publish.yml on cubos-d/RUSpectroscopy_Tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ruspectroscopy_tools-0.0.3-cp313-cp313-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for ruspectroscopy_tools-0.0.3-cp313-cp313-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 1c8bb026248b163e625bd2d5f765ebb8bfdf307a82a83bef329c0aa243de9191
MD5 875fa3168bbd2e6b34560363832cd9de
BLAKE2b-256 dc0d2abfd088ad451eb80caf408bc33bc274d75fea1ccec1b1b89542dc3cd156

See more details on using hashes here.

Provenance

The following attestation bundles were made for ruspectroscopy_tools-0.0.3-cp313-cp313-manylinux_2_17_i686.manylinux2014_i686.whl:

Publisher: pypi-publish.yml on cubos-d/RUSpectroscopy_Tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ruspectroscopy_tools-0.0.3-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for ruspectroscopy_tools-0.0.3-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 f903895e1ae53d561f50a6e36e835a994460920f4b488108f9a9a2fb1ff69349
MD5 5a4cf3166c51b77ad0e5c5876edd4474
BLAKE2b-256 f1622e43bb61b52148dcc07fba8450127ea141d58e8012dea578bebb8aeacf1d

See more details on using hashes here.

Provenance

The following attestation bundles were made for ruspectroscopy_tools-0.0.3-cp312-cp312-musllinux_1_2_x86_64.whl:

Publisher: pypi-publish.yml on cubos-d/RUSpectroscopy_Tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ruspectroscopy_tools-0.0.3-cp312-cp312-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for ruspectroscopy_tools-0.0.3-cp312-cp312-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 6c896361849b384ae73f840976562dac9708f01c200ade3faf87fe81d525f67b
MD5 21ca52bd5a9cd43210fff513c3cc9f97
BLAKE2b-256 c23659fd127bd55060f17167b4537dd136cc19da92f6a5de33be9a1f05dbc772

See more details on using hashes here.

Provenance

The following attestation bundles were made for ruspectroscopy_tools-0.0.3-cp312-cp312-musllinux_1_2_i686.whl:

Publisher: pypi-publish.yml on cubos-d/RUSpectroscopy_Tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ruspectroscopy_tools-0.0.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ruspectroscopy_tools-0.0.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6cc2dd5d2cea939fe1ee538297527c4865444e38982acb29e90527e6e1de2b7c
MD5 1cd7fa0dda1598abd319eb9f029e2fe5
BLAKE2b-256 9dddc27b1a710cf6fb94fa2f67c76521da71ef29cb3f1020a75940c7c5e54f52

See more details on using hashes here.

Provenance

The following attestation bundles were made for ruspectroscopy_tools-0.0.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: pypi-publish.yml on cubos-d/RUSpectroscopy_Tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ruspectroscopy_tools-0.0.3-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for ruspectroscopy_tools-0.0.3-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 5e8765253519968eefc9ed49efb12cc9c145e4e620624386d1522dc1d814207a
MD5 b552a0aff6073aa72a45d7c506c13e66
BLAKE2b-256 73a53da4ee9a669363414e00d98df119e51ec3fc6204beb055b6f21ee58e4301

See more details on using hashes here.

Provenance

The following attestation bundles were made for ruspectroscopy_tools-0.0.3-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl:

Publisher: pypi-publish.yml on cubos-d/RUSpectroscopy_Tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page