Open RobinSchmidt opened 5 years ago
yay! i can now superimpose the field lines over the vector field:
...but the user must provide a function to generate the field lines. generating them involves solving an ODE system - which i did for this plot analytically. the vector field is generated by the complex function f(z) = z^2
which corresponds to the vector valued function f(x,y) = (x^2-y^2, 2*x*y)
. wolfram alpha could solve the system analytically via DSolve[ {x'[t] == x[t]^2 - y[t]^2, y'[t] == 2 x[t] y[t]}, {x, y}, t]
and i implemented the resulting formulas. they are already quite messy, although it's perhaps the simplemost nonlinear example, one can think of (or...well...maybe not - only when you want to use a complex function to base the vector field on - which i want because i actually want to gain a better understanding of complex functions). i guess, a general field-line plotter will need a numerical ODE solver. ...i have some such stuff in the main RS-MET codebase but i probably don't want it here in the plotter. dunno...
...the vector valued function f(x,y) = (x^2-y^2, 2xy). wolfram alpha could solve the system analytically
i also tried to solve for the streamlines of the so called "Polya vector field" for z^2 - this just takes the complex conjugate, so we would just have to add a minus sign: f(x,y) = (x^2-y^2, -2xy). wolfram alpha says that it doesn't understand the input. wolfram cloud can do it - but the result is a total mess!
...i'm certainly not going to implement these formulas! :-O
...this wolfram cloud seems to be quite cool! https://www.wolframcloud.com/obj/robin13/Published/ZedSquaredFieldLines.nb ...these are the analytic formulas that i implemented for the field-line plot above. it's not pretty but still managable - this is actually a pair of two parametric equations for x and y in the parameter t and it was still tricky to figure out the appropriate range for the parameter t and when to switch between the formulas. ...but the polya field - nope - just nope!
phase portrait of a damped pendulum with one trajectory drawn in: ...this is basically the same kind of plot as a 2D vector field with one particular field-line drawn. the trajectory (pseudo field-line) was computed numerically with the simple forward euler method. i think, i'll integrate that simple solver into the plotter class. who wants to use more sophisticated solvers may have to generate the data themselves
the trajectory (pseudo field-line) was computed numerically with the simple forward euler method. i think, i'll integrate that simple solver into the plotter class.
ok, done. for quick-and-dirty plotting applications, the forward euler solver should be good enough. this plotter is not supposed to be a sophisticated ode solver. i think, i'm happy with the feature now and added this plot to the collection of demos:
i'd really like to be able to plot things like the field lines and equipotentials like at the very bottom here:
http://www.feynmanlectures.caltech.edu/II_04.html
...but i had to realize that i need a more sophisticated ode solver for such things (at the very least with adaptive stepsize control). and for the equipotentials probably an implicit equation solver. ...should i ever get around to implement these things, they'll probably go into a separate "add-on" file. maybe someday - but now, i have actual work to do :-)
...okay...i implemented adaptive stepsize control and can now do the field lines:
now with equipotentials:
...it almost starts to feel like creating an artwork - haha!
i just added some features that let us plot 2D vector fields. they look like this: