1D Electrolyte
Warning
If the Newton solver diverges for any of the solutions, you may try to reduce the relaxation parameter.
- Eq04.solve_System_4eq(phi_left: float, phi_right: float, p_right: float, z_A: float, z_C: float, y_A_R: float, y_C_R: float, K: float | str, Lambda2: float, a2: float, number_cells: int, solvation: float = 0, PoissonBoltzmann: bool = False, relax_param: float = None, x0: float = 0, x1: float = 1, refinement_style: str = 'uniform', return_type: str = 'Scalar', rtol: float = 1e-08, max_iter: float = 500)
Solve the dimensionless system of equations presented in: Numerical Treatment of a Thermodynamically Consistent Electrolyte Model, B.Sc. Thesis Habscheid 2024
- System of equations:
λ²Δ φ =−L²n^F
a²∇p=−n^F∇ φ
div(J_A)=0
div(J_C)=0
with φ the electric potential, p the pressure, n^F the total free charge density, J_α the diffusion fluxes of species α, λ² a dimensionless parameter, L²=1, a² a dimensionless parameter, N the number of species, and α the species index.
! If the Newton solver diverges, you may try to reduce the relaxation parameter.
- Parameters:
phi_left (float) – Value of φ at the left boundary
phi_right (float) – Value of φ at the right boundary
p_right (float) – Value of p at the right boundary
z_A (float) – Charge number of species A
z_C (float) – Charge number of species C
y_A_R (float) – Atomic fractions of species A at right boundary
y_C_R (float) – Atomic fractions of species C at right boundary
K (float | str) – Dimensioness bulk modulus of the electrolyte. If ‘incompressible’, the system is solved for an incompressible electrolyte
Lambda2 (float) – Dimensionless parameter
a2 (float) – Dimensionless parameter
number_cells (int) – Number of cells in the mesh
solvation (float, optional) – solvation number, by default 0
PoissonBoltzmann (bool, optional) – Solve classical Nernst-Planck model with the use of the Poisson-Boltzmann formulation if True, else solve the presented model by Dreyer, Guhlke, Müller, by default False
relax_param (float, optional) – Relaxation parameter for the Newton solver xₙ₊₁ = γ xₙ f(xₙ)/f’(xₙ) with γ the relaxation parameter , by default None -> Determined automatically
x0 (float, optional) – Left boundary of the domain, by default 0
x1 (float, optional) – Right boundary of the domain, by default 1
refinement_style (str, optional) – Specify for refinement towards zero Options are ‘uniform’, ‘log’, ‘hard_log’, ‘hard_hard_log’ by default ‘uniform’
return_type (str, optional) – ‘Vector’ or ‘Scalar’, ‘Scalar’ returns dolfinx.fem type and ‘Vector’ numpy arrays of the solution, by default ‘Scalar’
rtol (float, optional) – Relative tolerance for Newton solver, by default 1e-8
max_iter (float, optional) – Maximum number of Newton iterations, by default 500
- Returns:
Returns atomic fractions for species A and C, electric potential, pressure, and the mesh If return_type is ‘Vector’, the solution is returned as numpy arrays
- Return type:
y_A, y_C, phi, p, msh
- EqN.solve_System_Neq(phi_left: float, phi_right: float, p_right: float, z_alpha: list, y_R: list, K: float | str, Lambda2: float, a2: float, number_cells: int, solvation: float = 0, PoissonBoltzmann: bool = False, relax_param: float = None, x0: float = 0, x1: float = 1, refinement_style: str = 'uniform', return_type: str = 'Vector', rtol: float = 1e-08, max_iter: float = 500)
Solve the dimensionless system of equations presented in: Numerical Treatment of a Thermodynamically Consistent Electrolyte Model, B.Sc. Thesis Habscheid 2024
- System of equations:
λ²Δ φ =−L²n^F
a²∇p=−n^F∇ φ
div(J_α)=0 α∈ {1,…,N−1}
with φ the electric potential, p the pressure, n^F the total free charge density, J_α the diffusion fluxes of species α, λ² a dimensionless parameter, L²=1, a² a dimensionless parameter, N the number of species, and α the species index.
! If the Newton solver diverges, you may try to reduce the relaxation parameter.
- Parameters:
phi_left (float) – Value of φ at the left boundary
phi_right (float) – Value of φ at the right boundary
p_right (float) – Value of p at the right boundary
z_alpha (list) – Charge numbers for species α = 1,…,N-1
y_R (list) – Atomic fractions at right boundary for species α = 1,…,N-1
K (float | str) – Dimensioness bulk modulus of the electrolyte. If ‘incompressible’, the system is solved for an incompressible electrolyte
Lambda2 (float) – Dimensionless parameter
a2 (float) – Dimensionless parameter
number_cells (int) – Number of cells in the mesh
solvation (float, optional) – solvation number, not implemented yet, by default 0
PoissonBoltzmann (bool, optional) – Solve classical Nernst-Planck model with the use of the Poisson-Boltzmann formulation if True, else solve the presented model by Dreyer, Guhlke, Müller, Not implemented yet, by default False
relax_param (float, optional) – Relaxation parameter for the Newton solver xₙ₊₁ = γ xₙ f(xₙ)/f’(xₙ) with γ the relaxation parameter , by default None -> Determined automatically
x0 (float, optional) – Left boundary of the domain, by default 0
x1 (float, optional) – Right boundary of the domain, by default 1
refinement_style (str, optional) – Specify for refinement towards zero Options are ‘uniform’, ‘log’, ‘hard_log’, ‘hard_hard_log’ by default ‘uniform’
return_type (str, optional) – ‘Vector’ or ‘Scalar’ (not implemented yet, should be implemented in a later version), ‘Scalar’ returns dolfinx.fem type and ‘Vector’ numpy arrays of the solution, by default ‘Vector’
rtol (float, optional) – Relative tolerance for Newton solver, by default 1e-8
max_iter (float, optional) – Maximum number of Newton iterations, by default 500
- Returns:
Returns atomic fractions for species A and C, electric potential, pressure, and the mesh If return_type is ‘Vector’, the solution is returned as numpy arrays Only return_type ‘Vector’ is implemented yet
- Return type:
y_A, y_C, phi, p, msh
- Eq02.solve_System_2eq(phi_left: float, phi_right: float, p_right: float, z_A: float, z_C: float, y_A_R: float, y_C_R: float, K: float | str, Lambda2: float, a2: float, number_cells: int, solvation: float = 0, PoissonBoltzmann: bool = False, relax_param: float = None, x0: float = 0, x1: float = 1, refinement_style: str = 'uniform', return_type: str = 'Scalar', rtol: float = 1e-08, max_iter: float = 500)
Solve the simplified dimensionless system of equations presented in: Numerical Treatment of a Thermodynamically Consistent Electrolyte Model, B.Sc. Thesis Habscheid 2024
- System of equations:
λ²Δ φ =−L²n^F
a²∇p=−n^F∇ φ
- with the space charge
n^F = z_A y_A(φ, p) + z_C y_C(φ ,p)
- if the mixture is compressible:
y_alpha = C_alpha * (K+p−1)^(−κ+1)a²K exp(−z_α φ)
- if the mixture is incompressible:
y_alpha = D_alpha * exp(−(κ+1)a²p−z_α φ)
with φ the electric potential, p the pressure, n^F the total free charge density, J_α the diffusion fluxes of species α, λ² a dimensionless parameter, L²=1, a² a dimensionless parameter, N the number of species, and α the species index.
! If the Newton solver diverges, you may try to reduce the relaxation parameter.
- Parameters:
phi_left (float) – Value of φ at the left boundary
phi_right (float) – Value of φ at the right boundary
p_right (float) – Value of p at the right boundary
z_A (float) – Charge number of species A
z_C (float) – Charge number of species C
y_A_R (float) – Atomic fractions of species A at right boundary
y_C_R (float) – Atomic fractions of species C at right boundary
K (float | str) – Dimensioness bulk modulus of the electrolyte. If ‘incompressible’, the system is solved for an incompressible electrolyte
Lambda2 (float) – Dimensionless parameter
a2 (float) – Dimensionless parameter
number_cells (int) – Number of cells in the mesh
solvation (float, optional) – solvation number, by default 0
PoissonBoltzmann (bool, optional) – Solve classical Nernst-Planck model with the use of the Poisson-Boltzmann formulation if True, else solve the presented model by Dreyer, Guhlke, Müller, by default False
relax_param (float, optional) – Relaxation parameter for the Newton solver xₙ₊₁ = γ xₙ f(xₙ)/f’(xₙ) with γ the relaxation parameter , by default None -> Determined automatically
x0 (float, optional) – Left boundary of the domain, by default 0
x1 (float, optional) – Right boundary of the domain, by default 1
refinement_style (str, optional) – Specify for refinement towards zero Options are ‘uniform’, ‘log’, ‘hard_log’, ‘hard_hard_log’ by default ‘uniform’
return_type (str, optional) – ‘Vector’ or ‘Scalar’, ‘Scalar’ returns dolfinx.fem type and ‘Vector’ numpy arrays of the solution, by default ‘Scalar’
rtol (float, optional) – Relative tolerance for Newton solver, by default 1e-8
max_iter (float, optional) – Maximum number of Newton iterations, by default 500
- Returns:
Returns atomic fractions for species A and C, electric potential, pressure, and the mesh If return_type is ‘Vector’, the solution is returned as numpy arrays
- Return type:
y_A, y_C, phi, p, msh