Is there a way to calculate strain energy based on stress and deformation gradient? We know that we can obtain stress from strain energy density and deformation gradient, for example:
$$\mathbf P=\frac{\partial W}{\partial \mathbf F}$$
However, is there a way to calculate $W$ from $\mathbf F$ and $\mathbf P$? (Of course, we could also use other stress/deformation measures such as Cauchy stress, 2nd Piola-Kirchoff stress, left Cauchy Green tensor etc.)
 A: If you write your equation in component form, you get
\begin{equation}
P_{ij} = \frac{\partial W}{\partial F_{ij}},
\end{equation}
which is equivalent to
\begin{equation}
W = \int P_{ij}dF_{ij} = \int \tilde{P} \colon d\tilde{F},
\end{equation}
where $\tilde{P}$ and $\tilde{F}$ are the stress and strain tensors in Gibbs notation.
You can immediately see the analogy between this equation and the equivalent one in mechanics of a particle
\begin{equation}
W = \int \vec{F}\cdot d\vec{x}
\end{equation}
The stress is analogous to force and strain to displacement.
A: As $W$ is a potential for the stresses in $F_{ij}$, a Legendre-Fenchel-transformation to change the independent variable from strain to stress gives you the dual potential $W^*(P_{ij})$, where $ P_{ij}$ are the first Piola Kirchhoff stresses.
It is given by
$$
W^\ast(\mathbf{P})=\sup[{\mathbf{P}\cdot\mathbf{F}-W(\mathbf{F})}] \text{ over } \mathbf{F},
$$
where $\mathbf{P}\cdot\mathbf{F}$ is the scalar product, in indices w.r.t. an orthonormal basis this would be $\sum_{i,j} P_{ij}F_{ij}$.
There is a nice geometric interpretation to this in the 1D-case:
The strain energies $w(\varepsilon)$ and $w^\ast(\sigma)$ correspond to the areas that are enclosed by the axes and the actual stress-strain relation. They sum up to the so called final work $\sigma\varepsilon$.

It is rather exceptional that one can calculate $W^\ast$ directly. 


*

*First of all, it exists only when $W$ is convex in $\mathbf{F}$. It is well known that this requirement is at variance with principles of material modelling, specifically that the stored energy is invariant under rigid body rotations. In elasticity, $W(\mathbf{F})$ needs to be only quasiconvex. There are entire books on notions of convexity in elasticity, this is a seperate issue. In other words: If $W(\mathbf{F})$ complies with the principle of invariance under superimposed rigid body rotations, there exists no dual potential $W^\ast(\mathbf{P})$. It is more promising to write $W$ directly as a function of the right Cauchy-Green-tensor $\mathbf{C}=\mathbf{F}^T \mathbf{F}$, and search for the dual potential of the stress conjugate to $\mathbf{C}$, which would be the second Piola-Kirchhoff-Stresses (times two).

*Second, even if the potenital $W$ is convex, and $W^\ast$ exists, it may not be possible to write it down as a nice closed form expression. An example for this is Hutchinsons dissipation potential for the strain rate in the stresses, 
$$
D(\mathbf{T})=\sum_{i}\frac{1}{n+1}\left(\frac{\tau_i}{\tau_{\text{crit}}}\right)^{n+1},\quad \tau=\mathbf{T}\cdot \mathbf{d}_i\otimes\mathbf{n}_i, \quad n \text{ is an odd positive integer}
$$
where $\mathbf{d}_i$ and $\mathbf{n}_i$ are slip system vectors (crystal plasticity). It is convex, and upon differentiation w.r.t. the stresses $\mathbf{T}$ it gives you Hutchinsons celebrated flow rule for the strain rate $\dot{\mathbf{E}}$. However, it appears impossible to give a nice closed form expression for the supremum involved in the definition of $D^\ast(\dot{\mathbf{E})}$ if $n$ is larger than 1.


Hope this helps!
