diff --git a/packages/PyJuliaMPBSolver/.gitignore b/packages/PyJuliaMPBSolver/.gitignore deleted file mode 100644 index 581edad..0000000 --- a/packages/PyJuliaMPBSolver/.gitignore +++ /dev/null @@ -1 +0,0 @@ -**/dist diff --git a/packages/PyJuliaMPBSolver/PyJuliaMPBSolver/__init__.py b/packages/PyJuliaMPBSolver/PyJuliaMPBSolver/__init__.py deleted file mode 100644 index 78d85de..0000000 --- a/packages/PyJuliaMPBSolver/PyJuliaMPBSolver/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -import os -import sys -import warnings -from types import ModuleType -from typing import cast - - -def _import_juliacall(): - import juliacall - - -def _juliapkg_resolve(): - from juliapkg import resolve - - resolve() - - -_import_juliacall() - -from juliacall import Main as jl - -jl = cast(ModuleType, jl) - -jl.seval("using JuliaMPBSolver") -JuliaMPBSolver = jl.JuliaMPBSolver - -jl.seval("using Pkg: Pkg") -Pkg = jl.Pkg - -_juliapkg_resolve() - -from .core import JuliaMPBSolver diff --git a/packages/PyJuliaMPBSolver/PyJuliaMPBSolver/core.py b/packages/PyJuliaMPBSolver/PyJuliaMPBSolver/core.py deleted file mode 100644 index 37faf3d..0000000 --- a/packages/PyJuliaMPBSolver/PyJuliaMPBSolver/core.py +++ /dev/null @@ -1,127 +0,0 @@ -""" -Core solver module for JuliaSolver Python wrapper. - -This module provides the main NonlinearPoissonSolver class that wraps -the Julia implementation. -""" - -from typing import List, Tuple - -import numpy as np -from juliacall import Main as jl - - -class JuliaMPBSolver: - """ - Python wrapper for the JuliaDraftSolver nonlinear Poisson equation solver. - - This class provides a clean Python interface to solve 1D nonlinear Poisson - equations of the form: Δu^m = f - """ - - def __init__(self): - """ - Initialize the NonlinearPoissonSolver. - - The Julia environment is automatically set up when the package is imported. - """ - self._ensure_julia_ready() - - def _ensure_julia_ready(self): - """Ensure Julia modules are loaded.""" - # Julia environment is already set up by package import - # Just ensure the JuliaDraftSolver module is loaded - jl.seval("using JuliaMPBSolver") - - def mpbpsolve( - self, - n: int = 21, - domain: List[float] = [0, 10.0e-9], - chargenumbers: List[float] = [-1, 1], - bulkmolarity: float = 0.1, - surfacecharge: List[float] = [0.16, -0.16], - ) -> Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]: - """ - Solve the 1D nonlinear Poisson equation: Δu^m = f - - Args: - n: Number of grid points - domain: Domain boundaries [left, right] - bcval: Dirichlet boundary values [left_bc, right_bc] - source: Constant source term - m: Nonlinearity exponent - inival: Initial value for solver (if None, uses average of bcval) - - Returns: - Tuple of (x_coordinates, solution_values) as numpy arrays - - Example: - >>> solver = NonlinearPoissonSolver() - >>> x, u = solver.solve(n=31, domain=[0, 2], bcval=[0.5, 2.0], - ... source=2, m=3) - """ - self._ensure_julia_ready() - - # Call the Julia function - X, C0, Cp, Cm = jl.mpbpsolve( - n=n, - domain=domain, - chargenumbers=chargenumbers, - bulkmolarity=bulkmolarity, - surfacecharge=surfacecharge, - ) - - # Convert to numpy arrays. Note the call to collect to make sure - # we get an array rather than a Julia range. - x_values = np.array(jl.collect(X), copy=True) - c0_values = np.array(C0, copy=True) - cp_values = np.array(Cp, copy=True) - cm_values = np.array(Cm, copy=True) - - return x_values, c0_values, cp_values, cm_values - - def icmpbpsolve( - self, - n: int = 21, - domain: List[float] = [0, 10.0e-9], - chargenumbers: List[float] = [-1, 1], - averagemolarity: float = 1, - surfacecharge: List[float] = [0.16, -0.16], - ) -> Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]: - """ - Solve the 1D nonlinear Poisson equation: Δu^m = f - - Args: - n: Number of grid points - domain: Domain boundaries [left, right] - bcval: Dirichlet boundary values [left_bc, right_bc] - source: Constant source term - m: Nonlinearity exponent - inival: Initial value for solver (if None, uses average of bcval) - - Returns: - Tuple of (x_coordinates, solution_values) as numpy arrays - - Example: - >>> solver = NonlinearPoissonSolver() - >>> x, u = solver.solve(n=31, domain=[0, 2], bcval=[0.5, 2.0], - ... source=2, m=3) - """ - self._ensure_julia_ready() - - # Call the Julia function - X, C0, Cp, Cm = jl.icmpbpsolve( - n=n, - domain=domain, - chargenumbers=chargenumbers, - averagemolarity=averagemolarity, - surfacecharge=surfacecharge, - ) - - # Convert to numpy arrays - x_values = np.array(jl.collect(X)) - c0_values = np.array(C0) - cp_values = np.array(Cp) - cm_values = np.array(Cm) - - return x_values, c0_values, cp_values, cm_values diff --git a/packages/PyJuliaMPBSolver/PyJuliaMPBSolver/juliapkg.json b/packages/PyJuliaMPBSolver/PyJuliaMPBSolver/juliapkg.json deleted file mode 100644 index a7311be..0000000 --- a/packages/PyJuliaMPBSolver/PyJuliaMPBSolver/juliapkg.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "packages": { - "JuliaMPBSolver": { - "url": "https://github.com/IPAM-ECH2025/PoissonBoltzmannIPAM2025.git", - "subdir": "packages/JuliaMPBSolver", - "uuid": "d8b18f01-5396-498d-b34d-247825c18ff0" - } - } -} diff --git a/packages/PyJuliaMPBSolver/pyproject.toml b/packages/PyJuliaMPBSolver/pyproject.toml deleted file mode 100644 index d9b5dec..0000000 --- a/packages/PyJuliaMPBSolver/pyproject.toml +++ /dev/null @@ -1,17 +0,0 @@ -[build-system] -requires = ["hatchling"] -build-backend = "hatchling.build" - -[project] -name = "PyJuliaMPBSolver" -version = "0.1.0" -authors = [ - {name = "Jason Landini", email = "landinjm@umich.edu"}, -] -description = "Python wrapper for JuliaMPBSolver" -requires-python = ">=3.9" -dependencies = [ - "numpy>=1.20.0,<2.0.0", - "juliacall>=0.9.0", - "juliapkg" -] diff --git a/packages/PyJuliaMPBSolver/test.py b/packages/PyJuliaMPBSolver/test.py deleted file mode 100644 index a8acd51..0000000 --- a/packages/PyJuliaMPBSolver/test.py +++ /dev/null @@ -1,15 +0,0 @@ -from PyJuliaMPBSolver import JuliaMPBSolver - -print("precompiling & solving...") -solver = JuliaMPBSolver() -x, c0, cp, cm = solver.mpbpsolve() -print(x) -print(c0) -print(cm) -print(cp) - -x, c0, cp, cm = solver.icmpbpsolve() -print(x) -print(c0) -print(cm) -print(cp)