Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[Python] Why is the dFdt not giving me an array? I use the cross product. dBdt is printing out an array and v is initialized

[Python]

Why is the dFdt not giving me an array? I use the cross product. dBdt is printing out an array and v is initialized with s[0:2], shouldn't it print out an array?

image text in transcribed

In [79]: def func(s, t): VX, vy, x, y = 5 #initialize variables 9 = 1.602e-19 #C mue_const = le-7 I = 10 #Amps n = 100 #turns of wire in each coil R = .1 V = s[2:2] z = 5(2:4) dBdt = mue_const * (2*pi*R**2*I)/(2**2 + R**2) ** (3/2) dFdt = q* (np.cross(v, dBdt)) print (dBdt) print(dFdt) return concatenate ([dBdt,dFdt]) so = np.array ([1, 1, 0, .1]) ts = linspace(0,500,300) ans = odeint(func, so, ts, full_output = 1) [6.283185312-05 2.22144147e-85] -6.5069136286368435e-24 ValueError Traceback (most recent call last) in 19 se = np.array ([1, 1, 0, .1]) 20 ts = linspace(0,500,300) ---> 21 ans = odeint(func, se, ts, full_output = 1) - Anaconda3\lib\site-packages\scipy\integrate lodepack.py in odeint(func, yo, t, args, Dfun, col_deriv, full_output, ml, mu, rtol, atol, tcrit, ho, hmax, hmin, ixpr, mxstep, mxhnil, mxordn, mxords, printmessg, tfirst) 243 full_output, rtol, atol, tcrit, he, hmax, hmin, 244 ixpr, mxstep, mxhnil, mxordn, mxords, --> 245 int(bool(tfirst))) 246 if output[-1] in func(s, t) 15 print (dBdt) 16 print(dFdt) ---> 17 return concatenate([dBdt, dFdt]) 18 19 se = np.array ([1, 1, 0, .1]) <_array_function__ internals> in concatenate(*args, **kwargs) ValueError: all the input arrays must have same number of dimensions, but the array at index has 1 dimension(s) and the ar ray at index 1 has a dimension(s)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Successful Keyword Searching Initiating Research On Popular Topics Using Electronic Databases

Authors: Randall MacDonald, Susan MacDonald

1st Edition

0313306761, 978-0313306761

More Books

Students also viewed these Databases questions

Question

Would a two-tailed test of .26 be considered significant?

Answered: 1 week ago

Question

5. Discuss the key roles for training professionals.

Answered: 1 week ago