Python Forum
Error: _vhstack_dispatcher() takes 1 positional argument but 9 were given
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error: _vhstack_dispatcher() takes 1 positional argument but 9 were given
#1
Hi!

I have a system of 10 nonlinear ODE with 10 variables (y[0], y[1], ... y[9]), there are 10 initial conditions for y[i] for x=0 and 4 conditions for x = 6.804.

I try to solve a boundary value problem using scipy.integrate.solve_bvp according to the following algorithm: https://docs.scipy.org/doc/scipy/referen...e_bvp.html
I get the error "_vhstack_dispatcher() takes 1 positional argument but 9 were given" though I tried to use np.dstack instead of np.hstack. Please help to fix the error.

My code is below:
import numpy as np
from scipy.integrate import solve_bvp
import matplotlib.pyplot as plt
from scipy.constants import g

def fun(x, y):
    return np.vstack((ptb / y[4] * y[5] / np.sqrt(y[5]**2 + y[6]**2) * function_deo(y[4], y[5], y[6], y[9], ptb, mqb, pes) - 1 / y[2]**2 + y[1]**2 / y[2],
                      ptb / y[4] * y[6] / np.sqrt(y[5]**2 + y[6]**2) * function_deo(y[4], y[5], y[6], y[9], ptb, mqb, pes) - y[0] * y[1] / y[2]),
                     y[0], y[1] / y[2], 
                      -mqb * function_deo(y[4], y[5], y[6], y[9], ptb, mqb, pes), y[6] * y[1] / y[2] - y[7], -y[5] * 2.0 * y[1] / y[2] + y[6] * y[0] / y[2] - y[8] * 1.0 / y[2],
                      y[5] * (-2.0 / y[2]**3 + y[1]**2 / y[2]**2) + y[6] * (-y[0] * y[1]) / y[2] + y[8] * y[1] / y[2]**2, 0,
                       ptb / y[4]**2 * (np.sqrt(y[5]**2 + y[6]**2)) * function_deo(y[4], y[5], y[6], y[9], ptb, mqb, pes))
    

#Implement evaluation of the boundary condition residuals:

def bc(ya, yb):
    return np.array([ya[-0.03899746484, 1.05800280714, -0.30648856279, -0.605427, 1, -0.065851, 1.361805, 1.419320, -8.219418e-5, 0.6], yb[3.230021179060866e-17, 0.5519654178809713, 2.221001221001221, np.pi]])
#Define the initial mesh with 20 nodes:

x = np.linspace(0.0, 6.804, 20)

#To obtain solutions, different initial guesses for y are used. They are denoted by subscripts a and b.
y_a = np.zeros((10, x.size))
y_b = np.zeros((10, x.size))
y_b[0] = 3.230021179060866e-17

res_a = solve_bvp(fun, bc, x, y_a)
res_b = solve_bvp(fun, bc, x, y_b)

x_plot = np.linspace(0, 6.804, 100)
y_plot_a = res_a.sol(x_plot)[0]
y_plot_b = res_b.sol(x_plot)[0]
#plt.plot(x_plot, y_plot_a, label='y_a')
#plt.plot(x_plot, y_plot_b, label='y_b')
plt.legend()
plt.xlabel("x")
plt.ylabel("y")
plt.show()
Reply


Messages In This Thread
Error: _vhstack_dispatcher() takes 1 positional argument but 9 were given - by alexfrol86 - May-08-2022, 10:23 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  TypeError: Diagram.render() takes 1 positional argument but 2 were given sachin1361 0 322 Apr-23-2024, 06:39 AM
Last Post: sachin1361
  Strange argument count error rowan_bradley 3 825 Aug-06-2023, 10:58 AM
Last Post: rowan_bradley
  Error TypeError: output_type_handler() takes 2 positional arguments but 6 were given paulo79 1 2,070 Oct-17-2022, 06:29 PM
Last Post: paulo79
  What is positional argument self? Frankduc 22 6,148 Mar-06-2022, 01:18 AM
Last Post: Frankduc
  positional argument: 'self' mcmxl22 8 3,532 Dec-13-2021, 10:11 PM
Last Post: deanhystad
  TypeError: run_oracle_job() missing 1 required positional argument: 'connection_strin python_student 1 2,036 Aug-06-2021, 08:05 PM
Last Post: SheeppOSU
  int() argument Error.... but it's not :) LeoT 2 1,955 Feb-24-2021, 06:58 PM
Last Post: buran
  TypeError: sum() missing 1 required positional argument: 'num2' Insen 3 5,625 Jan-06-2021, 04:25 PM
Last Post: Insen
  TypeError: forward() missing 1 required positional argument: 'x' sveto4ka 4 12,480 Jun-17-2020, 07:25 PM
Last Post: sveto4ka
  missing 1 required positional argument: 'self' yasser 7 11,791 Jun-07-2020, 06:48 AM
Last Post: ndc85430

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020