Title: | Computation of Approximate Potentials for Weakly Non-Gradient Fields |
---|---|
Description: | Computation of approximate potentials for both gradient and non gradient fields. It is known from physics that only gradient fields, also known as conservative, have a well defined potential function. Here we present an algorithm, based on the classical Helmholtz decomposition, to obtain an approximate potential function for non gradient fields. More information in Rodríguez-Sánchez (2020) <doi:10.1371/journal.pcbi.1007788>. |
Authors: | Pablo Rodríguez-Sánchez |
Maintainer: | Pablo Rodríguez-Sánchez <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.1.0 |
Built: | 2025-02-11 04:27:48 UTC |
Source: | https://github.com/pabrod/waydown |
Approximate potential in one dimension
approxPot1D(f, xs, V0 = "auto")
approxPot1D(f, xs, V0 = "auto")
f |
One-dimensional representing the flow (right hand side of differential equation) |
xs |
Vector of positions to evaluate |
V0 |
(Optional) Value of V at first element of xs. When default, the global minimum is assigned 0 |
The potential estimated at each point in xs
Pablo Rodríguez-Sánchez (https://pabrod.github.io)
https://doi.org/10.1371/journal.pcbi.1007788
# Flow f = function(x) { sin(x) } # Sampling points xs <- seq(0, 2*pi, length.out = 1e3) # Approximated potential Vs <- approxPot1D(f, xs)
# Flow f = function(x) { sin(x) } # Sampling points xs <- seq(0, 2*pi, length.out = 1e3) # Approximated potential Vs <- approxPot1D(f, xs)
Approximate potential in two dimensions
approxPot2D(f, xs, ys, V0 = "auto", mode = "mixed")
approxPot2D(f, xs, ys, V0 = "auto", mode = "mixed")
f |
Two-dimensional representing the flow (right hand side of differential equation) |
xs |
Vector xs positions to evaluate |
ys |
Vector of ys positions to evaluate |
V0 |
(Optional) Value of V at first element of (xs,ys). When default, the global minimum is assigned 0 |
mode |
(Optional) Integration mode. Options are horizontal (default), vertical and mixed |
The potential estimated at each point (xs, ys)
Pablo Rodríguez-Sánchez (https://pabrod.github.io)
https://doi.org/10.1371/journal.pcbi.1007788
# Flow f = function(x) {c(-x[1]*(x[1]^2 - 1.1), -x[2]*(x[2]^2 - 1))} # Sampling points xs <- seq(-1.5, 1.5, length.out = 10) ys <- seq(-1.5, 1.5, length.out = 15) # Approximated potential Vs <- approxPot2D(f, xs, ys, mode = 'horizontal')
# Flow f = function(x) {c(-x[1]*(x[1]^2 - 1.1), -x[2]*(x[2]^2 - 1))} # Sampling points xs <- seq(-1.5, 1.5, length.out = 10) ys <- seq(-1.5, 1.5, length.out = 15) # Approximated potential Vs <- approxPot2D(f, xs, ys, mode = 'horizontal')
Approximate potential difference between two points
deltaV(f, x, x0, normType = "f")
deltaV(f, x, x0, normType = "f")
f |
Flow equations (right hand side of differential equation) |
x |
Position where we want to know the approximate potential |
x0 |
Reference position (center of the Taylor expansion) |
normType |
(default: 'f') Matrix norm used to compute the error |
A list containing the approximate potential difference between x and x0 and the estimated error
Pablo Rodríguez-Sánchez (https://pabrod.github.io)
https://doi.org/10.1371/journal.pcbi.1007788
approxPot1D, approxPot2D, norm
# One dimensional flow f <- function(x) { cos(x) } # Evaluation points x0 <- 1 x1 <- 1.02 dV <- deltaV(f, x1, x0) # Two dimensional flow f <- function(x) { c( -2*x[1]*x[2], -x[1]^2 - 1 )} # Evaluation points x0 <- matrix(c(1,2), ncol = 1) x1 <- matrix(c(0.98,2.01), ncol = 1) dV <- deltaV(f, x1, x0)
# One dimensional flow f <- function(x) { cos(x) } # Evaluation points x0 <- 1 x1 <- 1.02 dV <- deltaV(f, x1, x0) # Two dimensional flow f <- function(x) { c( -2*x[1]*x[2], -x[1]^2 - 1 )} # Evaluation points x0 <- matrix(c(1,2), ncol = 1) x1 <- matrix(c(0.98,2.01), ncol = 1) dV <- deltaV(f, x1, x0)