Fast Mie calculation lib with C++ backend
Project description
ARTmie
ARTmie is a python library to calculate optical properties of spherical particles.
Those can be simple, single coated or drawn from a particle size distribution.
ARTmie uses a lot of improved C++ in the backend for accelaration of various calculations.
The Code was mainly ported from Matlab and Fortran to C++.
Installation
from the Python Package Index (PyPI)
pip install ARTmie
from source
- Download the source code from this git by clicking the triangular button next to
Codeand selecting e.g. zip underneath Download source code. - Extract the source code to a desired location.
- Open a terminal with an appropriate python environment (Python 3.0 or higher) and Numpy (1.5 or higher, tested with 2.0).
- Change to the directory of the ARTmie project (dir above src):
cd /path/to/ARTmie
- Install it with the following command:
python -m pip install .
Requirements
- Python 3.0 or higher
- Numpy 1.5 or higher, preferable 2.0 or higher
- On windows with VS-Code: Microsoft Visual C++ 14.0 or higher
Example
Calculating the Mie efficiencies for extinction, scattering, absoprtion and backscattering for a glass sphere (crown glass, BK7) depending on the wavelength
Refractive index data are taken from wikipedia and refractiveindex.info
#import libraries
import numpy as np
np.set_printoptions(threshold=200)
import matplotlib.pyplot as plt
import ARTmie
#setup date
wavelength = np.linspace(200.0, 2000.0, 1000) #nanometers
w2 = (wavelength/1000.0)**2
b1,b2,b3,c1,c2,c3 = 1.03961212,0.231792344,1.01046945,6.00069867e-3,2.00179144e-2,103.560653
m_bk7 = np.sqrt(1.0+w2*(b1/(w2-c1)+b2/(w2-c2)+b3/(w2-c3))) #real part, from wikipedia (see above)
m_bk7 = m_bk7+9.7525e-9*1j #imaginary part, fix value, because its variability can be neglected (from refractiveindex.info see above)
diam = 200.0 #nanometers
#calculate Mie efficiencies
mie = ARTmie.MieQ(m_bk7,diam,wavelength, asDict=True)
print(mie)
{'Qext': array([4.41564110e+00, 4.28610971e+00, 4.17518991e+00, ...,
2.23387660e-03, 2.22560118e-03, 2.21736348e-03], shape=(1000,)), 'Qsca': array([4.41564090e+00, 4.28610952e+00, 4.17518973e+00, ...,
2.23387013e-03, 2.22559471e-03, 2.21735702e-03], shape=(1000,)), 'Qabs': array([1.98117068e-07, 1.88077067e-07, 1.78400203e-07, ...,
6.47562109e-09, 6.46930174e-09, 6.46299577e-09], shape=(1000,)), 'Qback': array([1.87779191, 1.78529354, 1.67319268, ..., 0.00319725, 0.00318568,
0.00317416], shape=(1000,)), 'Qratio': array([0.4252592 , 0.41653008, 0.4007465 , ..., 1.43125931, 1.43138174,
1.43150385], shape=(1000,)), 'Qpr': array([1.53362294, 1.4964994 , 1.45816498, ..., 0.00219041, 0.00218237,
0.00217437], shape=(1000,)), 'g': array([0.652684 , 0.65084905, 0.65075484, ..., 0.01945852, 0.01942341,
0.0193884 ], shape=(1000,))}
#plot the results
plt.figure()
ax = plt.gca()
ax.plot(wavelength, mie['Qext'], ls='-', label='Qext')
ax.plot(wavelength, mie['Qsca'], ls='--', label='Qsca')
ax.plot(wavelength, mie['Qabs'], ls='-.', label='Qabs')
ax.plot(wavelength, mie['Qback'], ls=':', label='Qback')
ax.set_xlabel('wavelength [nm]')
ax.set_ylabel('efficiency [--]')
ax.set_title('Scattering efficiencies of BK7 crown glass')
ax.legend()
plt.show()
License
ARTmie is available under the 3-Clause BSD license. See LICENSE for license information.
Contributor(s)
Enrico P. Metzner
Roadmap
for version 0.2.0:
- 1dimensional arrays for input arguments sizepar1 & sizepar2 in Size_Distribution_Optics and Size_Distribution_Phase_Function
- Size_Distribution_Phase_Function can also take an array of angles (theta) instead of predefined equally spaced 721 angles from 0° to 180°
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file artmie-0.1.2.tar.gz.
File metadata
- Download URL: artmie-0.1.2.tar.gz
- Upload date:
- Size: 65.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1fc5570b8d0aacd51b5fc57a3cf22f540c3b92ff3eaa1a0e945d7eeb1dce40d
|
|
| MD5 |
d339057620e1b0ebad242ebc12869878
|
|
| BLAKE2b-256 |
6f40375dc7449544bd5d9297fb40fe972e28aa67091ae04d2b4ab76550b96faa
|
Provenance
The following attestation bundles were made for artmie-0.1.2.tar.gz:
Publisher:
publish-pypi.yml on e-p-metzner/ARTmie
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
artmie-0.1.2.tar.gz -
Subject digest:
d1fc5570b8d0aacd51b5fc57a3cf22f540c3b92ff3eaa1a0e945d7eeb1dce40d - Sigstore transparency entry: 248457071
- Sigstore integration time:
-
Permalink:
e-p-metzner/ARTmie@4f0e0e3a86bc0dbe65925d1366f6db33e701d7cb -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/e-p-metzner
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@4f0e0e3a86bc0dbe65925d1366f6db33e701d7cb -
Trigger Event:
push
-
Statement type: