Skip to content

Commit 2e9b7d3

Browse files
committed
Remove numba dependency
1 parent 9c8e960 commit 2e9b7d3

File tree

8 files changed

+106
-116
lines changed

8 files changed

+106
-116
lines changed

.github/workflows/build_wheels.yml

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
fail-fast: false
1818
matrix:
1919
buildplat:
20-
- [ "ubuntu-latest", "auto", "", 'FC="gfortran" CC="gcc" CXX="g++"' ]
20+
- [ "ubuntu-latest", "x86_64 i686", "", 'FC="gfortran" CC="gcc" CXX="g++"' ]
2121
- [ "windows-latest", "AMD64", "MINGW64", 'FC="gfortran" CC="gcc" CXX="g++"' ]
2222
- [ "macos-13", "x86_64", "", 'MACOSX_DEPLOYMENT_TARGET=13.0 FC="gfortran" CC="gcc" CXX="g++"' ]
2323
- [ "macos-14", "arm64", "", 'MACOSX_DEPLOYMENT_TARGET=14.0 FC="gfortran" CC="gcc" CXX="g++"' ]
@@ -58,31 +58,30 @@ jobs:
5858
name: cibw-wheels-${{ matrix.buildplat[0] }}-${{ matrix.buildplat[1] }}
5959
path: ./wheelhouse/*.whl
6060

61-
# publish-to-testpypi:
62-
# name: Publish to TestPyPI
63-
# needs: build_wheels
64-
# runs-on: ubuntu-latest
65-
# if: github.event_name == 'push'
66-
# steps:
67-
# - name: Download all wheel artifacts
68-
# uses: actions/download-artifact@v4
69-
# with:
70-
# path: ./dist
71-
# pattern: cibw-wheels-*
72-
# merge-multiple: true
73-
# - name: Publish package to TestPyPI
74-
# uses: pypa/gh-action-pypi-publish@release/v1
75-
# with:
76-
# password: ${{ secrets.TestPYPI_API_TOKEN }}
77-
# repository-url: https://test.pypi.org/legacy/
78-
# skip-existing: true
61+
publish-to-testpypi:
62+
name: Publish to TestPyPI
63+
needs: build_wheels
64+
runs-on: ubuntu-latest
65+
if: github.event_name == 'push'
66+
steps:
67+
- name: Download all wheel artifacts
68+
uses: actions/download-artifact@v4
69+
with:
70+
path: ./dist
71+
pattern: cibw-wheels-*
72+
merge-multiple: true
73+
- name: Publish package to TestPyPI
74+
uses: pypa/gh-action-pypi-publish@release/v1
75+
with:
76+
password: ${{ secrets.TestPYPI_API_TOKEN }}
77+
repository-url: https://test.pypi.org/legacy/
78+
skip-existing: true
7979

8080
publish-to-pypi:
8181
name: Publish to PyPI
8282
needs: build_wheels
8383
runs-on: ubuntu-latest
84-
# if: github.event_name == 'release' && github.event.action == 'published'
85-
if: github.event_name == 'push'
84+
if: github.event_name == 'release' && github.event.action == 'published'
8685

8786
steps:
8887
- name: Download all wheel artifacts

.gitignore

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
11

22
.DS_Store
3-
.obsidian
4-
53
**/.DS_Store
6-
**/.so
4+
.DS_Store/
75

86

97
# Byte-compiled / optimized / DLL files
108
**/__pycache__/
119
*.py[cod]
1210
*$py.class
1311

14-
# C extensions
15-
**/.so
12+
# Test files
13+
# tests/
14+
tests/DependancyCheck.py
15+
tests/*.csv
16+
tests/Test12_FindTransition.py
17+
tests/TestLeveling.py
18+
tests/guitest.py
19+
tests/test.py
20+
ProgressStatus.md
21+
bdist_wheel.ps1
22+
bdist_wheel.sh
1623

1724
#Custom folders
25+
**/*.so
26+
**/*.mod
1827
archive/
1928
# database/
2029
literature/
@@ -23,6 +32,7 @@ presentations/
2332
writing/
2433
ongoing/
2534
.vscode/
35+
.obsidian/
2636

2737
# Distribution / packaging
2838
.Python

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
![PyPI - Version](https://img.shields.io/pypi/v/equilipy)
2-
![PyPI - Downloads](https://img.shields.io/pypi/dm/equilipy)
1+
[![PyPI - Version](https://img.shields.io/pypi/v/equilipy)](https://pypi.org/project/equilipy/)
2+
[![PyPI - Downloads](https://img.shields.io/pypi/dm/equilipy)](https://pypistats.org/packages/equilipy)
33
[![DOI](https://joss.theoj.org/papers/10.21105/joss.06875/status.svg)](https://doi.org/10.21105/joss.06875)
4+
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.17408401.svg)](https://doi.org/10.5281/zenodo.17408401)
45

56
# Equilipy
67
Equilipy is an open-source python package that offers multicomponent multiphase equilibrium calculations based on the CALPHAD (CALculation of PHAse Diagram) approach. With a set of Gibbs energy description (Thermochemical database) and input conditions (Composition, temperature, pressure), equilibrium phase configureation, amount, composition, and thermochemical properties can be obtained. Equilipy uses the Gibbs energy descriptions furnished by THERMOCHIMICA with the modified Gibbs energy minimization algorithm initially proposed by de Capitani, C. and Brown, T.H. (1987).
@@ -35,7 +36,7 @@ For details, check out the example directory and [Features and Examples](https:/
3536

3637
If you use Equilipy in your work, please cite the following [paper](CITATION.bib).
3738
In addition, cite the current release or version used from
38-
[Zenodo](https://zenodo.org/doi/10.5281/zenodo.13157231).
39+
[Zenodo](https://doi.org/10.5281/zenodo.17408401).
3940

4041
## Contributing
4142
We encourage you to contribute to Equilipy. Please see [contributing guidelines](CONTRIBUTING.md).

equilipy/EquilibBatch.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
# from mpi4py.futures import MPIPoolExecutor
1515
# from mpi4py import MPI
1616
from multiprocessing import Pool
17-
from numba import njit
1817

1918

2019
def _equilib_batch(Database:dict,NTP:dict,UnitIn:list=['K','atm','moles'],UnitOut:list=None,ListOfPhases:list=None):

equilipy/Simplex.py

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import numpy as np, math
2-
from numba import njit
2+
from equilipy.equilifort import simplex_grid_f
33

44
def simplex_count(nVertex:int,nSpacing:int):
55
'''
@@ -42,32 +42,10 @@ def simplex_grid(nVertex:int,nSpacing:int):
4242
return np.asarray(_simplex_grid(L,nVertex,nSpacing))
4343

4444

45-
@njit
46-
def _simplex_grid(L,nVer,nSpacing):
47-
res = np.zeros((L, nVer))
48-
49-
vertices=np.zeros(nVer)
50-
vertices[nVer-1] = nSpacing
51-
52-
for i in range(nVer):
53-
res[0, i] = vertices[i]
54-
55-
h = nVer
5645

57-
for i in range(1, L):
58-
h -= 1
59-
60-
val = vertices[h]
61-
vertices[h] = 0
62-
vertices[nVer-1] = val - 1
63-
vertices[h-1] += 1
64-
65-
for j in range(nVer):
66-
res[i, j] = vertices[j]
67-
68-
if val != 1:
69-
h = nVer
70-
return res/nSpacing
46+
def _simplex_grid(L,nVer,nSpacing):
47+
res = simplex_grid_f(L,nVer,nSpacing)
48+
return res
7149

7250

7351
def simplex_grid_shift(SimplexGrid,CornerVertex:int,ShrinkFactor:float):

equilipy/SystemCheck.py

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import numpy as np, sys
2-
from numba import njit
32
import equilipy.variables as var
43
import equilipy.equilifort as fort
54

@@ -59,13 +58,6 @@ def system_check(cElementSys):
5958
j+=1
6059
var.iElementSys=var.iElementSys[var.iElementSysIndex]
6160

62-
# #Identify species that can pass for the system
63-
# lSpeciesPass = _get_species_pass(iElementPass)
64-
# if sum(lSpeciesPass) == 0:
65-
# lSpeciesPass = _get_endmembers(iElementPass)
66-
# fort.moduleparsecs.lendmembers2species= True
67-
# else:
68-
# fort.moduleparsecs.lendmembers2species= False
6961

7062
lSpeciesPass = _get_endmembers(iElementPass)
7163
fort.moduleparsecs.lendmembers2species= True
@@ -108,56 +100,7 @@ def system_check(cElementSys):
108100

109101
return None
110102

111-
@njit
112-
def _get_species_pass(iElementPass):
113-
#This function identifies which species to be considered for a given system
114-
115-
#Get elements not considered in the system
116-
iElementNotPass= iElementPass.nonzero()[0]
117-
118-
#First guess the species that need to be considered
119-
res=np.sum(var.dStoichSpeciesCS[:,iElementNotPass],axis=1)<1E-15
120-
121-
# Refine the species based on solution phases
122-
# Note that solution phase should have more than one endmember, otherwise remove the endmembers
123-
124-
#Get solution index
125-
IndexSoln=var.iPhaseCS[res]
126-
n=len(res)
127-
m = len(IndexSoln)
128-
k=0
129-
130-
for i in range(n):
131-
# Among the species that need to be passed in database
132-
if res[i]:
133-
if (k==0):
134-
# Condition for the first endmembers
135-
136-
if (IndexSoln[k]>0) and (IndexSoln[k]==IndexSoln[k+1]):
137-
#If more than two endmembers are involved add the phase
138-
res[i] = True
139-
else:
140-
res[i] = False
141-
k+=1
142-
elif k==m-1:
143-
# Condition for the last endmembers
144-
if ((IndexSoln[k]>0) and (IndexSoln[k]==IndexSoln[k-1])):
145-
# If more than two endmembers are involved add the phase
146-
res[i] = True
147-
else:
148-
res[i] = False
149-
k+=1
150-
elif k<m-1:
151-
# Condition for endmembers that are inbetween
152-
if (IndexSoln[k]!=IndexSoln[k-1]) and (IndexSoln[k]!=IndexSoln[k+1]) and (IndexSoln[k]>0):
153-
res[i]=False
154-
elif IndexSoln[k]==-1:
155-
res[i]=False
156-
k+=1
157-
158-
return res
159103

160-
@njit
161104
def _get_endmembers(iElementPass):
162105
#This function identifies which species to be considered for a given system
163106

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
subroutine simplex_grid_f(L, nVer, nSpacing, res)
2+
!>
3+
!> @param[in] L The number of grid points to generate (rows).
4+
!> @param[in] nVer The number of vertices (columns).
5+
!> @param[in] nSpacing The integer value to be partitioned.
6+
!> @param[out] res The resulting (L, nVer) grid, normalized by nSpacing.
7+
integer, intent(in) :: L
8+
integer, intent(in) :: nVer
9+
integer, intent(in) :: nSpacing
10+
real, dimension(L, nVer), intent(out) :: res
11+
12+
! --- Local variables ---
13+
integer, dimension(nVer) :: vertices ! Stores the integer partitions
14+
integer :: h, val, i, j
15+
real :: nSpacing_real
16+
17+
! --- Initialization ---
18+
vertices = 0
19+
vertices(nVer) = nSpacing
20+
21+
! --- Copy first row ---
22+
do j = 1, nVer
23+
! Implicit conversion from integer to real
24+
res(1, j) = vertices(j)
25+
end do
26+
27+
! --- Main loop to generate subsequent rows ---
28+
h = nVer + 1
29+
30+
do i = 2, L
31+
h = h - 1
32+
33+
val = vertices(h)
34+
35+
vertices(h) = 0
36+
37+
vertices(nVer) = val - 1
38+
39+
vertices(h-1) = vertices(h-1) + 1
40+
41+
! Copy the new 'vertices' state to the result row
42+
do j = 1, nVer
43+
res(i, j) = vertices(j)
44+
end do
45+
46+
! (Resets h to one-past-the-end)
47+
if (val /= 1) then
48+
h = nVer + 1
49+
end if
50+
51+
end do
52+
53+
! --- Final Normalization ---
54+
55+
! Cast nSpacing to real for floating-point division
56+
nSpacing_real = real(nSpacing)
57+
58+
! Fortran can perform element-wise array operations
59+
res = res / nSpacing_real
60+
61+
end subroutine simplex_grid_f

pyproject.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ requires = ["setuptools>=42", "wheel", "numpy>=1.23", "meson", "ninja", "cibuild
88

99
[project]
1010
name = "equilipy"
11-
version = "0.1.7"
11+
version = "0.1.8"
1212
authors = [
1313
{name = "Sunyong Kwon", email = "[email protected]"},
1414
]
@@ -19,15 +19,14 @@ requires-python = ">=3.9"
1919
dependencies = [
2020
"numpy>=1.23",
2121
"regex",
22-
"numba",
2322
"dataclasses",
2423
"meson",
2524
"ninja",
2625
"polars>=0.20.15",
2726
"xlsx2csv",
28-
"matplotlib",
2927
"tqdm",
3028
"fastexcel",
29+
"typing",
3130
]
3231

3332
[project.scripts]

0 commit comments

Comments
 (0)