Skip to content

Replace Hard-Coded Derivatives with Automatic Differentiation #41

@carlosra0345

Description

@carlosra0345

Currently, the derivatives in this codebase are hard-coded as direct differentiations of their original functions, most of which are taken from the original MATLAB implementation nmmoc_surf_nuemann.m. This approach introduces maintainability issues, increases the risk of errors, and makes extending or modifying the code difficult.

Affected Derivatives

The derivatives that are currently hard-coded include:

  • σ (the IFT equation)

  • IFT with respect to surfactant concentration

  • Residual saturations with respect to surfactant concentration

  • Normalized saturations with respect to surfactant concentration

  • Relative permeability with respect to surfactant concentration

  • Relative permeability with respect to saturation

  • Fractional flow with respect to saturation and concentrations

  • Capillary pressure with respect to saturation and concentrations

Suggested Improvement

Consider replacing these hard-coded derivatives with automatic differentiation where possible. This would:

  • Reduce maintenance overhead when modifying underlying functions.

  • Minimize human error in derivative calculations.

  • Facilitate extension to new functional forms or additional variables.

Metadata

Metadata

Labels

enhancementNew feature or request
No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions