def make_force(q_vars, mass):
    """Fluxion with the potential energy of the eight planets sytem"""
    # Number of bodies
    B: int = len(mass)
    
    # Build the potential energy fluxion by iterating over distinct pairs of bodies
    U = fl.Const(0.0)
    for i in range(B):
        for j in range(i+1, B):
            U +=  U_ij(q_vars, mass, i, j)
    
    # Varname arrays for both the coordinate system and U
    vn_q = np.array([q.var_name for q in q_vars])
    vn_fl = np.array(sorted(U.var_names))
    # Permutation array for putting variables in q in the order expected by U (alphabetical)
    q2fl = np.array([np.argmax((vn_q == v)) for v in vn_fl])
    # Permutation array for putting results of U.diff() in order of q_vars
    fl2q = np.array([np.argmax((vn_fl == v)) for v in vn_q])
    # Return a force function from this potential
    force_func = lambda q: -U.diff(q[q2fl]).squeeze()[fl2q]
    return force_func
def make_force ( q_vars , mass ) : B : int = len ( mass ) U = fl . Const ( 0.0 ) for i in range ( B ) : for j in range ( i + 1 , B ) : U += U_ij ( q_vars , mass , i , j ) vn_q = np . array ( [ q . var_name for q in q_vars ] ) vn_fl = np . array ( sorted ( U . var_names ) ) q2fl = np . array ( [ np . argmax ( ( vn_q == v ) ) for v in vn_fl ] ) fl2q = np . array ( [ np . argmax ( ( vn_fl == v ) ) for v in vn_q ] ) force_func = lambda q : - U . diff ( q [ q2fl ] ) . squeeze ( ) [ fl2q ] return force_func
Fluxion with the potential energy of the eight planets sytem