Permeability
About
Calculate permeability of porous media using the seepage distance method, derived from the Darcy's law-based formula
Details
- Author
- 1vewton
- Categories
- Other
- Tags
- #research, #data-analysis, #education
Jump to
Setup
Install Permeability in your MCP client (Claude Desktop, Cursor, Windsurf, and others).
Repository: https://github.com/1vewton/permeability
Follow the installation instructions in the repository README, then restart your MCP client.
Calculate Permeability from Experimental Data
from permeability.permeability import Seepage # Experimental parameters K = Seepage.calculate_permeability( L=0.003, # Sample thickness: 3 mm mu=0.192, # Fluid viscosity: 0.192 Pa·s phi=0.445, # Porosity: 0.445 t=100, # Penetration time: 100 s dP=1e4 # Pressure difference: 10,000 Pa ) print(f"Permeability: {K:.3e} m²") # ~3.84e-13 m²
t = Seepage.calculate_infiltration_time( L=0.003, mu=0.192, phi=0.445, K=3.8448e-13, dP=1e4 ) print(f"Infiltration time: {t:.2f} s") # ~100.00 s
# Single time point z = Seepage.calculate_infiltration_front_position( K=1.284e-13, mu=0.192, phi=0.642, dP=1e5, t=120 ) print(f"Front position: {z:.4f} m") # ~0.0050 m # Multiple time points (for graphing) import numpy as np z_array = Seepage.calculate_infiltration_front_position_with_multiple_time( K=1.284e-13, mu=0.192, phi=0.642, dP=1e5, t=np.array([0, 30, 120]) ) print(f"Front positions: {z_array}") # [0.0, 0.0025, 0.005]
from permeability.permeability.Capillary import calculate_capillary_pressure # Capillary pressure via Young-Laplace equation p_c = calculate_capillary_pressure( gamma=0.072, # Surface tension of water: 0.072 N/m theta=30, # Contact angle: 30 degrees r=1e-6 # Pore radius: 1 µm ) print(f"Capillary pressure: {p_c:.2f} Pa") # ~124.71 Pa
# Calculate permeability considering capillary pressure K_corrected = Seepage.calculate_permeability( L=0.003, mu=0.192, phi=0.445, t=100, dP=1e4, p_c=124.71 # Capillary pressure (Pa) ) print(f"Corrected permeability: {K_corrected:.3e} m²")
# Calculate the pressure difference applied across the sample dP = Seepage.calculate_pressure_difference( L=0.003, mu=0.192, phi=0.445, K=3.8448e-13, t=100 ) print(f"Pressure difference: {dP:.2f} Pa") # ~10000.00 Pa # With capillary correction dP_corrected = Seepage.calculate_pressure_difference( L=0.003, mu=0.192, phi=0.445, K=3.8448e-13, t=100, p_c=124.71 # Capillary pressure (Pa) ) print(f"Corrected pressure difference: {dP_corrected:.2f} Pa")
from permeability.utils.UnitConverter import darcy2m2, m22darcy # Convert m² to Darcy darcy = m22darcy(m2K=3.8448e-13) print(f"Permeability: {darcy:.3f} Darcy") # ~0.390 Darcy # Convert Darcy to m² m2 = darcy2m2(darcyK=0.3896) print(f"Permeability: {m2:.3e} m²") # ~3.845e-13 m²
For orthotropic materials (e.g., woven composites), thePermeabilityTensorclass represents a diagonal permeability tensor $K = \text{diag}(K_x, K_y, K_z)$.
from permeability.permeability.AnisotropicTensor import PermeabilityTensor # Construct from principal values (orthotropic) tensor = PermeabilityTensor.from_principal_values( Kx=1e-12, # Warp/fiber direction (m²) Ky=5e-13, # Weft direction (m²) Kz=1e-13 # Through-thickness direction (m²) ) # Isotropic tensor iso_tensor = PermeabilityTensor.from_isotopic(K=1e-12) # Transversely isotropic (e.g., unidirectional fiber bundles) trans_tensor = PermeabilityTensor.from_transversely_isotropic( K_in_plane=1e-12, K_out_plane=1e-13 )
# 3x3 diagonal matrix print(tensor.tensor) # Average in-plane permeability (Kx + Ky) / 2 print(f"In-plane avg: {tensor.in_plane_average:.3e} m²") # Anisotropy ratio β = in_plane_avg / Kz print(f"Anisotropy ratio: {tensor.anisotropy_ratio:.2f}") # Degree of anisotropy (0 = isotropic, 1 = fully anisotropic) print(f"Degree of anisotropy: {tensor.degree_of_anisotropy:.3f}") # Export to dictionary print(tensor.to_dict())
import numpy as np # Darcy velocity: v = -(1/μ) · K · ∇p grad_p = np.array([1000, 500, 100]) # Pressure gradient (Pa/m) v = tensor.darcy_velocity(grad_p=grad_p, mu=0.192) print(f"Darcy velocity: {v} m/s")
# Along principal axes print(tensor.effective_permeability_in_direction(direction='x')) print(tensor.effective_permeability_in_direction(direction='xy')) # in-plane avg # In an arbitrary direction n = np.array([1, 1, 0]) # arbitrary direction vector print(tensor.effective_permeability_in_direction(direction_vector=n))
Theanisotropic_darcy_fluxfunction computes Darcy flux and related quantities in anisotropic media.
from permeability.permeability.AnisotropicTensor import ( PermeabilityTensor, anisotropic_darcy_flux ) tensor = PermeabilityTensor.from_principal_values( Kx=1e-12, Ky=5e-13, Kz=1e-13 ) result = anisotropic_darcy_flux( tensor=tensor, grad_p=np.array([1000, 500, 100]), # Pa/m mu=0.192, # Pa·s area_normal=np.array([1, 0, 0]) # Optional: unit normal of cross-section ) print(f"Darcy velocity: {result['darcy_velocity']} m/s") print(f"Flux magnitude: {result['flux_magnitude']:.3e} m/s") print(f"Velocity angle from gradP: {result['velocity_angle_from_gradP_deg']:.2f}°") print(f"Area flux: {result['area_flux']:.3e} m³/s per m²")
Theanisotropy_evolutionfunction analyzes how permeability anisotropy evolves over multiplePIP (Polymer Infiltration and Pyrolysis) cycles, which is critical for understanding the densification process of ceramic matrix composites (CMCs).
$$ K_i = \begin{bmatrix} K_{x,i} & 0 & 0 \ 0 & K_{y,i} & 0 \ 0 & 0 & K_{z,i} \end{bmatrix} ,\qquad \beta_i = \frac{K_{\text{in-plane},i}}{K_{z,i}} ,\qquad \delta_i = 1 - \frac{\min(K_{x,i}, K_{y,i}, K_{z,i})}{\max(K_{x,i}, K_{y,i}, K_{z,i})} $$
$$ \text{Anisotropy Reduction} = \frac{\beta_0 - \beta_n}{\beta_0} \times 100% $$
from permeability.permeability.AnisotropicTensor import anisotropy_evolution import numpy as np # Permeability data across PIP cycles: each row = [Kx, Ky, Kz] K_data = np.array([ [1.0e-12, 5.0e-13, 1.0e-13], # Cycle 0 (as-processed) [8.0e-13, 4.5e-13, 1.5e-13], # Cycle 1 [6.0e-13, 4.0e-13, 2.0e-13], # Cycle 2 [4.5e-13, 3.5e-13, 2.5e-13], # Cycle 3 ]) cycles = np.array([0, 1, 2, 3]) result = anisotropy_evolution(K_values=K_data, cycles=cycles) # Access results for i, cycle in enumerate(result['cycles']): print(f"Cycle {cycle}: β = {result['anisotropy_ratios'][i]:.2f}, " f"δ = {result['degrees_of_anisotropy'][i]:.3f}") print(f"Anisotropy reduction: {result['anisotropy_reduction']:.1f}%")
The package includes aModel Context Protocol (MCP) serverthat exposes permeability calculations as AI-accessible tools. After[installing the package, start the server with:
# Default port 8000 (HTTP/SSE transport) permeability_mcp # Custom port permeability_mcp --port 8080
The server starts via HTTP/SSE transport (http://localhost:8000by default).
If you prefer to try it without installing, you can also use:
uvx --from permeability permeability_mcp
For clients that support the modernStreamable HTTPtransport (MCP spec), the server can be configured to use HTTP POST-based communication instead of SSE:
permeability_mcp --port 8000 # Then connect via Streamable HTTP at http://localhost:8000/mcp
Claude Desktopconfiguration using Streamable HTTP (claude_desktop_config.json):
{ "mcpServers": { "permeability": { "type": "http", "url": "http://localhost:8000/mcp" } } }
Cline (VS Code extension)configuration using Streamable HTTP:
{ "mcpServers": { "permeability": { "type": "http", "url": "http://localhost:8000/mcp" } } }
Note:The Streamable HTTP transport requires a client that supports the MCP Streamable HTTP specification. The server runs the same underlying implementation — only the transport protocol differs from the default SSE-based connection.
Once the MCP server is running, AI assistants can call:
Each tool accepts the same parameters as the Python API.
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.



