Original Question
I have a set of non-linear equations and I need to find the root where a subset of my solution vector is constrained to be greater than or equal to 0. I have implemented the Newton-Raphson algorithm but I am finding that some of the quantities that I need to remain positive are going negative. I am familiar with using Lagrange multipliers to enforce constraints in an optimization problem but I'm unsure about how to do the same for root finding.
It had occurred to me that I could map my variables which must be positive to log space (i.e., solve for $\log(x_i)$ rather than $x_i$) but since zero is an important case I was worried that this might cause numerical problems.
From a previous answer it looks like an interior point method might be appropriate but it would involve modifying my solver rather than just the residual equation which I would like to avoid.
Further Description
The equations are a series of non-linear equations arising from a material model which incorporates irrecoverable deformation ( $E^p$ ). The way that this is typically achieved is through internal state variables ($\xi$) which are governed through some evolution equations which are determined by some evolution rate ( $\dot{\gamma}$ ).
The evolution equations take the form of:
$\dot{E^p} = \dot{E}\left(E^p,\xi, \dot{\gamma}\right)$
$\dot{\xi} = \dot{\xi}\left( \xi, \dot{\gamma}\right)$
Subject to some additional onset condition ( yield function ):
$F=F(E - E^p)$
where $E$ is the total deformation which is a function which is <= 0. The problem is subject to a Kuhn-Tucker condition which can be summarized as:
$\dot{\gamma}F = 0$
Implying that the evolution rate is zero if $F < 0$ and $\dot{\gamma}>0$ if $F=0$.
My unknown vector is something like:
$x=\left[ E^p, \xi, \gamma \right]$
My residual is something like:
$R=\left[{ E }^{p,expected} - E^p, \xi^{expected} - \xi, \dot{\gamma}F + \langle F \rangle \right]$
Where the values marked $\left(\cdot\right)^{expected}$ are the results of the evolution equations and $\langle \cdot \rangle$ are the Macaulay brackets which are defined as:
$\langle x \rangle = \frac{1}{2}\left( x + abs( x ) \right)$
I include the Macaulay term because, otherwise, the case of F > 0 and $\dot{\gamma}=0$ would be accepted which is incorrect. I tried using if statement in the residual calculation but that caused other issues and this seems to be performing better.