After getting this great tip https://ask.sagemath.org/question/46123/arrow-length-goes-wild-near-poles-in-vector-field-plot/
I wanted to use the second approach and changed my code to this:
======
load( 'e-feld.sage')
pic=phi_ges.subs({
Q : 1e-9,
d_e : 1,
z_s : .25,
z_c : .5,
epsilon_m : 76,
epsilon_s : 21.75,
epsilon_0 : 8.854187817e-12
})
grad_phi_ges = -phi_ges.gradient([x,z]).simplify()
pic=grad_phi_ges.subs({
Q : 1e-9,
d_e : 1,
z_s : .25,
z_c : .5,
epsilon_m : 76,
epsilon_s : 21.75,
epsilon_0 : 8.854187817e-12
})
grad_len = abs(grad_phi_ges)
my_grad = [lambda x,z: grad_phi_ges[0].subs(x=x,z=z) if
grad_len.subs(x=x,z=z) < 7 else None,
lambda x,z: grad_phi_ges[1].subs(x=x,z=z) if
grad_len.subs(x=x,z=z) < 7 else None]
plot_vector_field(my_grad, (x,-1,1), (z,-1,1), color='blue',
plot_points=22, axes_labels=['$x$ in [m]','$z$ in [m]'],typeset='latex',
frame=True, axes=False).save('vektorplot_gradient.png')
and when executing that last line sage goes off and does not come back.
when pressing Ctrl-C after a while i got this traceback. perhaps you can
tell me what is wrong and how i could avoid it?
please find attached also the file that i source in the beginning.
^C---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-1-9f045102c5a2> in <module>()
----> 1 load('contour-und-vektor-plot.sage')
/usr/lib/python2.7/dist-packages/sage/misc/persist.pyx in
sage.misc.persist.load (build/cythonized/sage/misc/persist.c:2471)()
134
135 if sage.repl.load.is_loadable_filename(filename):
--> 136 sage.repl.load.load(filename, globals())
137 return
138
/usr/lib/python2.7/dist-packages/sage/repl/load.pyc in load(filename,
globals, attach)
261 add_attached_file(fpath)
262 with open(fpath) as f:
--> 263 exec(preparse_file(f.read()) + "\n", globals)
264 elif ext == '.spyx' or ext == '.pyx':
265 if attach:
<string> in <module>()
/usr/lib/python2.7/dist-packages/sage/misc/decorators.pyc in wrapper(*args,
**kwds)
490 options['__original_opts'] = kwds
491 options.update(kwds)
--> 492 return func(*args, **options)
493
494 #Add the options specified by @options to the signature of
the wrapped
/usr/lib/python2.7/dist-packages/sage/plot/plot_field.pyc in
plot_vector_field(f_g, xrange, yrange, **options)
269 xpos_array.append(x)
270 ypos_array.append(y)
--> 271 xvec_array.append(f(x, y))
272 yvec_array.append(g(x, y))
273
<string> in <lambda>(x, z)
/usr/lib/python2.7/dist-packages/sage/symbolic/expression.pyx in
sage.symbolic.expression.Expression.__nonzero__
(build/cythonized/sage/symbolic/expression.cpp:19262)()
2884 if pynac_result == relational_notimplemented and
self.operator()==operator.ne:
2885 return not
(self.lhs()-self.rhs()).is_trivial_zero()
-> 2886 res = self.test_relation()
2887 if res is True:
2888 return True
/usr/lib/python2.7/dist-packages/sage/symbolic/expression.pyx in
sage.symbolic.expression.Expression.test_relation
(build/cythonized/sage/symbolic/expression.cpp:19878)()
2993 if domain is None:
2994 is_interval = True
-> 2995 if self.lhs().is_algebraic() and
self.rhs().is_algebraic():
2996 if op == equal or op == not_equal:
2997 domain = QQbar
/usr/lib/python2.7/dist-packages/sage/symbolic/expression.pyx in
sage.symbolic.expression.Expression.is_algebraic
(build/cythonized/sage/symbolic/expression.cpp:15061)()
2009 """
2010 try:
-> 2011 ex = sage.rings.all.QQbar(self)
2012 except (TypeError, ValueError, NotImplementedError):
2013 return False
/usr/lib/python2.7/dist-packages/sage/structure/parent.pyx in
sage.structure.parent.Parent.__call__
(build/cythonized/sage/structure/parent.c:9238)()
887 if mor is not None:
888 if no_extra_args:
--> 889 return mor._call_(x)
890 else:
891 return mor._call_with_args(x, args, kwds)
/usr/lib/python2.7/dist-packages/sage/structure/coerce_maps.pyx in
sage.structure.coerce_maps.DefaultConvertMap_unique._call_
(build/cythonized/sage/structure/coerce_maps.c:4659)()
160 print(type(C), C)
161 print(type(C._element_constructor),
C._element_constructor)
--> 162 raise
163
164 cpdef Element _call_with_args(self, x, args=(), kwds={}):
/usr/lib/python2.7/dist-packages/sage/structure/coerce_maps.pyx in
sage.structure.coerce_maps.DefaultConvertMap_unique._call_
(build/cythonized/sage/structure/coerce_maps.c:4551)()
155 cdef Parent C = self._codomain
156 try:
--> 157 return C._element_constructor(x)
158 except Exception:
159 if print_warnings:
/usr/lib/python2.7/dist-packages/sage/rings/qqbar.pyc in
_element_constructor_(self, x)
1162 return AlgebraicNumber(x._descr)
1163 elif hasattr(x, '_algebraic_'):
-> 1164 return x._algebraic_(QQbar)
1165 return AlgebraicNumber(x)
1166
/usr/lib/python2.7/dist-packages/sage/symbolic/expression.pyx in
sage.symbolic.expression.Expression._algebraic_
(build/cythonized/sage/symbolic/expression.cpp:11757)()
1510 """
1511 from sage.symbolic.expression_conversions import algebraic
-> 1512 return algebraic(self, field)
1513
1514 def __hash__(self):
/usr/lib/python2.7/dist-packages/sage/symbolic/expression_conversions.pyc
in algebraic(ex, field)
1140 0
1141 """
-> 1142 return AlgebraicConverter(field)(ex)
1143
1144 ##############
/usr/lib/python2.7/dist-packages/sage/symbolic/expression_conversions.pyc
in __call__(self, ex)
215 div = self.get_fake_div(ex)
216 return self.arithmetic(div, div.operator())
--> 217 return self.arithmetic(ex, operator)
218 elif operator in relation_operators:
219 return self.relation(ex, operator)
/usr/lib/python2.7/dist-packages/sage/symbolic/expression_conversions.pyc
in arithmetic(self, ex, operator)
986 elif operator is mul_vararg:
987 operator = _operator.mul
--> 988 return reduce(operator, map(self, ex.operands()))
989 except TypeError:
990 pass
/usr/lib/python2.7/dist-packages/sage/symbolic/expression_conversions.pyc
in __call__(self, ex)
215 div = self.get_fake_div(ex)
216 return self.arithmetic(div, div.operator())
--> 217 return self.arithmetic(ex, operator)
218 elif operator in relation_operators:
219 return self.relation(ex, operator)
/usr/lib/python2.7/dist-packages/sage/symbolic/expression_conversions.pyc
in arithmetic(self, ex, operator)
978 from sage.rings.all import Rational
979 base, expt = ex.operands()
--> 980 base = self.field(base)
981 expt = Rational(expt)
982 return self.field(base**expt)
/usr/lib/python2.7/dist-packages/sage/structure/parent.pyx in
sage.structure.parent.Parent.__call__
(build/cythonized/sage/structure/parent.c:9238)()
887 if mor is not None:
888 if no_extra_args:
--> 889 return mor._call_(x)
890 else:
891 return mor._call_with_args(x, args, kwds)
/usr/lib/python2.7/dist-packages/sage/structure/coerce_maps.pyx in
sage.structure.coerce_maps.DefaultConvertMap_unique._call_
(build/cythonized/sage/structure/coerce_maps.c:4659)()
160 print(type(C), C)
161 print(type(C._element_constructor),
C._element_constructor)
--> 162 raise
163
164 cpdef Element _call_with_args(self, x, args=(), kwds={}):
/usr/lib/python2.7/dist-packages/sage/structure/coerce_maps.pyx in
sage.structure.coerce_maps.DefaultConvertMap_unique._call_
(build/cythonized/sage/structure/coerce_maps.c:4551)()
155 cdef Parent C = self._codomain
156 try:
--> 157 return C._element_constructor(x)
158 except Exception:
159 if print_warnings:
/usr/lib/python2.7/dist-packages/sage/rings/qqbar.pyc in
_element_constructor_(self, x)
1162 return AlgebraicNumber(x._descr)
1163 elif hasattr(x, '_algebraic_'):
-> 1164 return x._algebraic_(QQbar)
1165 return AlgebraicNumber(x)
1166
/usr/lib/python2.7/dist-packages/sage/symbolic/expression.pyx in
sage.symbolic.expression.Expression._algebraic_
(build/cythonized/sage/symbolic/expression.cpp:11757)()
1510 """
1511 from sage.symbolic.expression_conversions import algebraic
-> 1512 return algebraic(self, field)
1513
1514 def __hash__(self):
/usr/lib/python2.7/dist-packages/sage/symbolic/expression_conversions.pyc
in algebraic(ex, field)
1140 0
1141 """
-> 1142 return AlgebraicConverter(field)(ex)
1143
1144 ##############
/usr/lib/python2.7/dist-packages/sage/symbolic/expression_conversions.pyc
in __call__(self, ex)
215 div = self.get_fake_div(ex)
216 return self.arithmetic(div, div.operator())
--> 217 return self.arithmetic(ex, operator)
218 elif operator in relation_operators:
219 return self.relation(ex, operator)
/usr/lib/python2.7/dist-packages/sage/symbolic/expression_conversions.pyc
in arithmetic(self, ex, operator)
986 elif operator is mul_vararg:
987 operator = _operator.mul
--> 988 return reduce(operator, map(self, ex.operands()))
989 except TypeError:
990 pass
/usr/lib/python2.7/dist-packages/sage/symbolic/expression_conversions.pyc
in __call__(self, ex)
215 div = self.get_fake_div(ex)
216 return self.arithmetic(div, div.operator())
--> 217 return self.arithmetic(ex, operator)
218 elif operator in relation_operators:
219 return self.relation(ex, operator)
/usr/lib/python2.7/dist-packages/sage/symbolic/expression_conversions.pyc
in arithmetic(self, ex, operator)
993 from sage.symbolic.constants import e, pi, I
994 base, expt = ex.operands()
--> 995 if base == e and expt / (pi*I) in QQ:
996 return exp(expt)._algebraic_(self.field)
997
/usr/lib/python2.7/dist-packages/sage/symbolic/expression.pyx in
sage.symbolic.expression.Expression.__nonzero__
(build/cythonized/sage/symbolic/expression.cpp:19379)()
2897 # lot of basic Sage objects can't be put into maxima.
2898 from sage.symbolic.relation import test_relation_maxima
-> 2899 return test_relation_maxima(self)
2900
2901 self_is_zero = self._gobj.is_zero()
/usr/lib/python2.7/dist-packages/sage/symbolic/relation.pyc in
test_relation_maxima(relation)
500 if relation.operator() == operator.eq: # operator is equality
501 try:
--> 502 s = m.parent()._eval_line('is
(equal(%s,%s))'%(repr(m.lhs()),repr(m.rhs())))
503 except TypeError:
504 raise ValueError("unable to evaluate the predicate
'%s'" % repr(relation))
/usr/lib/python2.7/dist-packages/sage/interfaces/maxima_lib.pyc in
_eval_line(self, line, locals, reformat, **kwds)
454 line = line[ind_semi+1:]
455 if statement:
--> 456 result = ((result + '\n') if result else '') +
max_to_string(maxima_eval("#$%s$"%statement))
457 else:
458 statement = line[:ind_dollar]
/usr/lib/python2.7/dist-packages/sage/libs/ecl.pyx in
sage.libs.ecl.EclObject.__call__ (build/cythonized/sage/libs/ecl.c:7937)()
818 """
819 lispargs = EclObject(list(args))
--> 820 return
ecl_wrap(ecl_safe_apply(self.obj,(<EclObject>lispargs).obj))
821
822 def __richcmp__(left, right, int op):
/usr/lib/python2.7/dist-packages/sage/libs/ecl.pyx in
sage.libs.ecl.ecl_safe_apply (build/cythonized/sage/libs/ecl.c:5599)()
390 if ecl_nvalues > 1:
391 s = si_coerce_to_base_string(ecl_values(1))
--> 392 raise RuntimeError("ECL says: {}".format(
393 char_to_str(ecl_base_string_pointer_safe(s))))
394 else:
RuntimeError: ECL says: Console interrupt.
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.
e-feld.sage
Description: Binary data
