I am having some trouble trying to solve a nonlinear system of equations numerically using fsolve from scipy.optimize. I solve this system for a lot of multiples and sub-multiples of one parameter (nuc_den), the solution is good for one third of this parameter values (the error is low), I start from the lowest sob-multiple and go solving and increasing the value of the multiples and using the previous fsolve answer as the guess for the next attempt of solution. But after some interactions fsolve finds the solution for the system with a major error in one of the variables (err = 10^5) and after that all solutions, for all variables, have the same previous value (when the error started to be enormous) for the remaining values of this parameter.
The variables are (SIGMA, k_n, k_p, k_e, k_mu, k_lam) and as for the system:
(self.m_SIGMA**2)*SIGMA + self.b*self.m_n*(self.g_SIGMA**3)*(SIGMA**2) + self.c*(
self.g_SIGMA**4)*(SIGMA**3) - self.g_SIGMA*(ns_p + ns_n + ns_lam),
k_p - np.power(k_e**3 + k_mu**3, 1/3),
k_p**3 + k_n**3 + k_lam**3 - nuc_den*(3*(np.pi**2)),
np.sqrt(k_mu**2 + self.m_mu**2) - np.sqrt(k_e**2 + self.m_e**2),
np.sqrt(k_n**2 + m_eff_n**2) - np.sqrt(k_p**2 + m_eff_p**2) - np.sqrt(k_e**2 + self.m_e**2
) - ((self.g_RHO**2)/(self.m_RHO**2))*((k_p**3 - k_n**3)/(6*(np.pi**2))),
np.sqrt(k_lam**2 + m_eff_lam**2) - np.sqrt(k_n**2 + m_eff_n**2) - (1/(9*np.pi**2)
)*(self.g_OMEGA**2/(self.m_OMEGA**2))*(k_n**3 + k_p**3 + (2/3)*k_lam**3) +
(1/(6*np.pi**2))*(self.g_RHO**2/(self.m_RHO**2))*((1/2)*k_p**3 - (1/2)*k_n**3)
The shortcuts here are: ns_n, ns_p, ns_lam and every term with "_eff", they are:
ns_n = (1/(2*(np.pi**2)))*(k_n*np.sqrt((k_n)**2 + (m_eff_n)**2) -
(m_eff_n**2)*np.log((k_n + np.sqrt((k_n)**2 + (m_eff_n)**2))/m_eff_n))*m_eff_n
the same for ns_p and ns_lam, only changing the indexes in the variables. And:
m_eff_n = self.m_n - self.g_SIGMA*SIGMA
again the same for the others, only changing the indexes.
I have already check the equations numerous of times, for months, doesn't seems to be anything wrong with them. So, I don't know what else to do, maybe it is the way I wrote the system or something else.