How to calculate eccentricity of a planet via energy? The relative distance of a planet moving around the sun is found to be:
$$r(\varphi) = \dfrac{\kappa}{1+\varepsilon\,\cos(\varphi)} \quad \text{where} \quad \kappa = \dfrac{L^2}{G\,{m_p}^2\,m_s} \quad \varepsilon = \sqrt{\dfrac{2\,E\,L^2}{G\,{m_p}^3\,m_s}}$$
Where $m_p$ is the mass of the planet, $m_s \gg m_p$ the mass of the sun and $G$ the gravitational constant.
In this case I just like to focus on the eccentricity $\varepsilon$. How do I determine this thing?
What troubles me is the definition of the total Energy: $E = \dfrac{1}{2}m_p\,\dot{r}^2 + \dfrac{L^2}{2\,m\,r^2}-\dfrac{G^,m_s\,m_p}{r}$
As well as the definition of the angular momentum: $L = r\times m_s\,\dot{r}$. The only question is:
$\textbf{What values do I choose for $r$ and $\dot{r}$} ?$ Distance from the earth to the sun and velocity on its orbit? But these are changing with time!
Alternatively there is this geometric formula: $\varepsilon = \dfrac{r_{max}-r_{min}}{r_{max}+r_{min}}$ that I don't like to use.
 A: The eccentricity is independent of the total orbital energy.
We can rewrite your first equation in terms of $a$, the semimajor axis of the orbit.
$$r = \frac{a(1 - \varepsilon^2)}{1+\varepsilon\,\cos(\varphi)}$$
At any point on the orbit, the speed is given by the vis-viva equation, which is a consequence of the invariance of the orbital energy.
$$v^2 = \mu\left(\frac2r - \frac1a\right)$$
where $\mu=GM$ is the sum of the standard gravitational parameters of the Sun & the planet (it's common to omit the planet's mass because it's so small relative to the Sun's).
For a circular orbit, where $\varepsilon=0$ and $r\equiv a$, the equation simplifies to
$$v^2 = \frac\mu a$$
Rearranging the vis-viva equation, we get the specific orbital energy, that is, the orbital energy per unit mass:
$$\frac{v^2}2 - \frac\mu{r} = -\frac\mu{2a}$$
In that equation, $\frac{v^2}2$ is the specific kinetic energy and $-\frac\mu{r}$ is the specific potential energy. So all orbits with the same $a$ have the same specific orbital energy.

The ellipses in the following diagram all have $a=1$ and a focus at the origin, so they all have identical specific energy.

Here are the same ellipses, but rotated about the focus so that they all pass through $(1, 0)$.

At that point, $r=a=1$. From vis-viva, all the orbits pass through that point with the same speed, so they all have the same specific kinetic energy there, and of course they have the same specific potential energy there because they're the same distance from the Sun.
The orbits all have identical orbital period $T$, given by
$$a^3 =\mu\left(\frac{T^2}{4\pi^2}\right)$$

Here's the Sage / Python script that I used to create those diagrams, running on SageMathCell.
A: There is no unique relationship between eccentricity and total mechanical energy. One must know (somehow) the angular momentum, $L$, also. I believe your equations demonstrate that clearly since the eccentricity is related to the quantity, $\sqrt{EL^2}$, and $E$ is not uniquely dependent on $L$.
Notice that at the aphelion $L=m_pr_{max}v_{min}$ and at the perihelion $L=m_pr_{min}v_{max}$. At these points $\dot{r}=0$.
With a little calculus to find the radius of curvature at the aphelion (it's not $a(1+\epsilon)$) or perihelion (not $a(1-\epsilon)$), one can show that
$$ \frac{2m_pE}{L^2}=\frac{-1}{b^2}  \text{ and } \frac{Gm_pm_s}{E}=-2a,$$
where $b$ is the length of the semi-minor axis
and $a$ is the length of the semi-major axis.
