# Scaling/nondimensionalization for numerical optimization

I have a numerical optimization problem that I am trying to scale appropriately, in order to allow for the solver to achieve faster and more accurate results. I found a paper here that had a short section on nondimensionalization on page 44, that simply stated the following:

In order to nondimensionalize a quantity, just multiply by the appropriate constant.

The nondimensionalization constants are given by

$$n_{length}=\frac{1}{R_{P}}$$ $$n_{velocity}=\sqrt{\frac{R_{P}}{\mu}}$$ $$n_{mass}=\frac{1}{m_{0}}$$ $$n_{time}=\frac{n_{length}}{n_{velocity}}$$ $$n_{force}=\frac{n_{mass}n_{length}}{n_{time}^{2}}$$

where $R_{P}$ is the planet's radius, $\mu=GM$ is the planet's gravitational parameter and $m_{0}$ is the spacecraft's initial mass. I have very similar equations to those used in the thesis, where the following system of first-order ODEs describes the spacecraft's dynamics:

$$\dot{r_{x}} = v_{x}$$ $$\dot{r_{y}} = v_{y}$$ $$\dot{v_{x}} = -\frac{GMr_{x}}{||\mathbf{r}||^{3}}+\frac{T_{x}}{m}$$ $$\dot{v_{y}} = -\frac{GMr_{y}}{||\mathbf{r}||^{3}}+\frac{T_{y}}{m}$$ $$\dot{m} = -\frac{||\mathbf{T}||}{g_{0}I_{sp}}$$

I'm a little confused how I should go about actually implementing the nondimensionalization in order to discretize the equations in their scaled/nondimensionalized form. From my simple understanding of the topic, my nondimensionalized equations would look as follows:

EDIT: In response to Kirill's answer, would the transformed system of equations instead look as follows?

$$\dot{\tilde{r_{x}}} = \frac{n_{length}}{n_{time}}v_{x}$$ $$\dot{\tilde{r_{y}}} = \frac{n_{length}}{n_{time}}v_{y}$$ $$\dot{\tilde{v}_{x}} = \frac{n_{force}}{n_{mass}}\left(-\frac{GMr_{x}}{||\mathbf{r}||^{3}}+\frac{T_{x}}{m}\right)$$ $$\dot{\tilde{v}_{y}} = \frac{n_{force}}{n_{mass}}\left(-\frac{GMr_{y}}{||\mathbf{r}||^{3}}+\frac{T_{y}}{m}\right)$$ $$\dot{\tilde{m}} = \frac{n_{mass}}{n_{time}}\left(-\frac{||\mathbf{T}||}{g_{0}I_{sp}}\right)$$

EDIT 2: Since I'm not really understanding the answers given (apologies, I'm a bit slow), and can't seem to find any well explained examples online, I thought it may help if I show some of the code from the optimization problem I'm working on. Given the original system of ODEs, they are discretized using $N$ nodes, where the final time is given by $t_{f}$ and the time-step between nodes is given by $dt=t_{f}/N$. Thus, using a trapezoidal integration scheme, the system of ODEs is discretized as follows in MATLAB,

for t = 2:N
y(:,t) = (I-0.5*dt*A(:,:,t))\((I+0.5*dt*A(:,:,t-1))*y(:,t-1)+0.5*dt*B(u(:,t)+u(:,t-1)));
.
.
.
end


where the state vector is given by $y = [r_{x},r_{y},v_{x},v_{y},m]^{T}$ and the control vector is given by $u = [T_{x},T_{y},||\mathbf{T}||]^{T}$, with $A$ given by

A = [0 0 1 0 0;
0 0 0 1 0;
a 0 0 0 0;
0 a 0 0 0;
0 0 0 0 0]


wherea = -(G*M)/(norm(r(:,t)).^3), and

B = [0 0 0;
0 0 0;
1/m 0 0;
0 1/m 0;
0 0 -1/(g0*Isp)];


How could the above system be scaled? I thought about simply applying the following diagonal preconditioner to both the left and right-hand sides of the discretized equations

M_scale = [
n_length/n_time 0 0 0 0;
0 n_length/n_time 0 0 0;
0 0 n_force/n_mass 0 0;
0 0 0 n_force/n_mass 0;
0 0 0 0 n_mass/n_time];


where I then have

for t = 2:N
M_scale*y(:,t) = M_scale*(I-0.5*dt*A(:,:,t))\((I+0.5*dt*A(:,:,t-1))*y(:,t-1)+0.5*dt*B(u(:,t)+u(:,t-1)));
.
.
.
end


but unfortunately this doesn't seem to work.

• Non-dimensionalization is equivalent to a diagonal preconditioner. Depending on the numerical method being used for solving the optimization problem, this would or would not offer improvements. Sep 12, 2017 at 22:30
• @gpavanb, would I apply the diagonal pre-conditioner to the matrix that is formed from the system of equations given above, and leave the individual variables such as $x,y,v_{x},v_{y},m$ as they are, or do the variables also need to be changed somehow? That is, is the problem scaled at the variable level or at the equation level? Sep 16, 2017 at 17:28
• When doing a change of variables, you have to change the variables everywhere, not just the l.h.s. You are not applying the change of variables rule correctly: at the end you must get an ODE of the form $(\tilde x,\tilde y,\ldots) = f(\tilde x, \tilde y, \ldots)$, so you can't have leftover $x$ or $r$ or $v$ on the r.h.s. It might be easier to go to a calculus textbook for an explanation. Sep 17, 2017 at 17:45
• A side note: for orbital mechanics problems, i recommend using a higher order time integration scheme; 4th order runge-kutta at minimum. Additionally, non-dimensionalization is more of a matter of taste. You can certainly do the optimization without non-dimensionalization, but you just need to be careful if your goal is to replicate the results of the paper.
– Paul
Sep 21, 2017 at 0:39
• Thanks Paul, the optimization worked well without an atmospheric model, but now that drag has been added it's struggling to converge, and as such I thought that scaling the optimization variables may be able to solve the problem. Sep 21, 2017 at 6:51

Consider writing it in a different way: let there be a new set of variables, $\tilde t, \tilde x,\ldots$, all unitless, defined by $$\tilde t = n_{\mathrm{time}}t, \qquad \tilde x = n_{\mathrm{length}} x, \qquad \ldots$$ Then it's a straightforward change of variables, from $(x(t),\ldots)$ to $(\tilde x(\tilde t), \ldots)$, applied to the system of ODEs. You get $$\frac{\mathrm{d}\tilde x}{\mathrm{d}\tilde t} = \frac{n_{\mathrm{length}}}{n_{\mathrm{time}}} \dot x = \frac{n_{\mathrm{length}}}{n_{\mathrm{time}}} v_x = \frac{n_{\mathrm{length}}}{n_{\mathrm{time}}} \frac{\tilde v_x}{n_{\mathrm{length}}/n_{\mathrm{time}}} = \tilde v_x.$$ The slight danger in not doing this explicitly is that you might accidentally produce an inequivalent system of ODEs. The transformation between the two sets of variables must be an equivalence transformation, and so it should not change the actual system dynamics. Simply multiplying the r.h.s. by the factors is not valid for this reason.
The reason it's called nondimensionalization is because you change the units in which you measure all the quantities that enter the ODE, but the ODE itself remains the same. This is not the case for the ODE you gave, because if you look at $\dot x = \frac{n_l}{n_t}v_x$, this contradicts even the very definition of velocity.