[piecewise] AttributeError: ComplexField_class_with_category object has no attribute complex_field

22 views
Skip to first unread message

Marcel Partap

unread,
Oct 29, 2017, 6:14:54 AM10/29/17
to sage-support
For graphing strain load on a shaft in relation to coordinate x, I have created a set of piecewise functions. Now I wanted to munge them into a single parametrized vector to easily get the length via norm() at a specified point.

M_Tx = piecewise([[[0, l1], M_t], [(l1, l1+l2), 0]])
M_by
= piecewise([[[0, l1], -A_z * x], [(l1, l1+l2), -B_z * (l1+l2-x)]])
M_bz
= piecewise([[[0, l1], A_y * x], [(l1, l1+l2), B_y * (l1+l2-x)]])
N_x
= piecewise([[[0, l1], -A_x], [(l1, l1+l2), 0]])
Q_y
= piecewise([[[0, l1], -A_y], [(l1, l1+l2), B_y]])
Q_z
= piecewise([[[0, l1], -A_z], [(l1, l1+l2), B_z]])


M_vec
(x) = vector([M_Tx, M_by, M_bz]).column()
show
(r"$\vec M=\left(\begin{array}{c} M_{Tx} \\ M_{by} \\ M_{bz} \end{array}\right)=$", M_vec(x = l1).n(digits=4), "kN $=$", round(M_vec(x = l1).norm(), 4), "kN")



But, this does not work.

Error in lines 27-27
Traceback (most recent call last):
 
File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 996, in execute
   
exec compile(block+'\n', '', 'single') in namespace, locals
 
File "", line 1, in <module>
 
File "sage/structure/element.pyx", line 838, in sage.structure.element.Element.n (/ext/sage/sage-8.0/src/build/cythonized/sage/structure/element.c:7961)
   
return self.numerical_approx(prec, digits, algorithm)
 
File "sage/symbolic/expression.pyx", line 5718, in sage.symbolic.expression.Expression.numerical_approx (/ext/sage/sage-8.0/src/build/cythonized/sage/symbolic/expression.cpp:35056)
    x
= x._convert(kwds)
 
File "sage/symbolic/expression.pyx", line 1261, in sage.symbolic.expression.Expression._convert (/ext/sage/sage-8.0/src/build/cythonized/sage/symbolic/expression.cpp:10465)
    cdef
GEx res = self._gobj.evalf(0, kwds)
 
File "sage/libs/pynac/pynac.pyx", line 1343, in sage.libs.pynac.pynac.py_float (/ext/sage/sage-8.0/src/build/cythonized/sage/libs/pynac/pynac.cpp:15280)
   
return p.complex_field()(n)
 
File "sage/structure/category_object.pyx", line 823, in sage.structure.category_object.CategoryObject.__getattr__ (/ext/sage/sage-8.0/src/build/cythonized/sage/structure/category_object.c:7662)
   
return self.getattr_from_category(name)
 
File "sage/structure/category_object.pyx", line 838, in sage.structure.category_object.CategoryObject.getattr_from_category (/ext/sage/sage-8.0/src/build/cythonized/sage/structure/category_object.c:7826)
    attr
= getattr_from_other_class(self, cls, name)
 
File "sage/structure/misc.pyx", line 294, in sage.structure.misc.getattr_from_other_class (/ext/sage/sage-8.0/src/build/cythonized/sage/structure/misc.c:1866)
   
raise dummy_attribute_error
AttributeError: 'ComplexField_class_with_category' object has no attribute 'complex_field'


Is it that piecewise functions are not yet fully fledged out, or is my lack of sage routine that is to blame?
Any hints most welcome : )

#Best Regards/Marcel

Marcel Partap

unread,
Oct 29, 2017, 6:28:40 AM10/29/17
to sage-support
like basically, why don't the piecewise functions collapse to scalars? This should result in the same output, no?
M_vec(x) = vector([M_Tx(x), M_by(x), M_bz(x)]).column()
M_vec
(x = l1)
M_vec_l1
= vector([M_Tx(l1), M_by(x=l1), M_bz(x=l1)]).column()
M_vec_l1

gives instead
[                                        piecewise(x|-->238.732400000000 on [0, 200], x|-->0 on (200, 450); x)]
[ piecewise(x|-->-4.27033333333333*x on [0, 200], x|-->3.41626666666667*x - 1537.32000000000 on (200, 450); x)]
[piecewise(x|-->-0.983311111111111*x on [0, 200], x|-->1.07628888888889*x - 484.330000000000 on (200, 450); x)]
[ 238.732400000000]
[-854.066666666667]
[-196.662222222222]


Ralf Stephan

unread,
Oct 30, 2017, 6:35:33 AM10/30/17
to sage-support
On Sunday, October 29, 2017 at 11:14:54 AM UTC+1, Marcel Partap wrote:
Is it that piecewise functions are not yet fully fledged out,

This, unfortunately.

mforets

unread,
Oct 31, 2017, 1:26:07 AM10/31/17
to sage-support
Hi,
Is it a vector-valued PW function the functionality that you need? What do you mean by "collapsing to scalars"?
Reply all
Reply to author
Forward
0 new messages