Skip to content Skip to sidebar Skip to footer

Typeerror: Bad Operand Type For Abs(): 'referenceframe' But I Have No Abs() Function

I'm trying calculate the curl of a vector with its del operator, and so I'm using the curl from sympy and just having the vector cross with the reference frame, but I get this erro

Solution 1:

Use R[0] instead of x. I deduced this from the curl examples (and trying to replicate some Wiki examples)

Running in isympy

(Can't import curl from sympy)

In [2]: from sympy.physics.vector import curl, ReferenceFrame  
   ...: alpha = Symbol('\u03B1')  
   ...: B0 = Symbol('B0')    
   ...: R = ReferenceFrame('R')  
   ...: V = B0*sin(alpha*R[0])*R.y + B0*cos(alpha*R[0])*R.z  
   ...: print(V)  
   ...: C = curl(V,R)  
   ...: print(C)  
   ...:  
   ...:                                                                              
B0*sin(R_x*α)*R.y + B0*cos(R_x*α)*R.z
B0*α*sin(R_x*α)*R.y + B0*α*cos(R_x*α)*R.z

There may be a way of factoring out the alpha, or otherwise show that C is alpha*V. I'm just working through the sympy tutorials.

In[4]: expand(C-alpha*V)                                                            
Out[4]: 0In[8]: VOut[8]: B₀⋅sin(Rₓ⋅α) r_y + B₀⋅cos(Rₓ⋅α) r_zIn[9]: COut[9]: B₀⋅α⋅sin(Rₓ⋅α) r_y + B₀⋅α⋅cos(Rₓ⋅α) r_z

Post a Comment for "Typeerror: Bad Operand Type For Abs(): 'referenceframe' But I Have No Abs() Function"