ⓘ This web page is about the old AlgoSim 2 software. Perhaps you are looking for the new Algosim 3 application?
AlgoSim
Homepage | Screenshots | Gallery of Visualisation | User's Guide | Function Reference | Download | FAQ | Support | Bugs and Solutions | Donate

Reference: createVectorField

createVectorField(expr, vars, set) creates a vector field from the equation expr. expr is a string representing a real vector-valued expression in two variables, given by vars, a comma-separated string of the valid identifiers. expr(x, y) is supposed to give the vector at the point (x, y) in the plane. The resulting set is a vector field, a set of vectors (x, y, vx, vy) associating a vector (vx(x, y), vy(x, y)) to each point (x, y) in the plane. set is the set of points (x, y) for which the expression expr is evaluated.

Examples: Vertical constant vector field (e.g. gravity):
          gravity ≔ createVectorField("❨0, -1❩", "x, y", [-10, 10]^2)
          drawVectorField("gravity", "colour:#333333")

          Horizontal linear vector field (e.g. a spring force)
          force ≔ createVectorField("❨-x, 0❩", "x, y", [-10, 10]^2)
          drawVectorField("force", "colour:#333333")

          An oscillating chemical reaction
          a ≔ 2
          b ≔ 3.001

          vectorField ≔ createVectorField("❨1 + a⋅x^2⋅y − b⋅x−x, -a⋅x^2⋅y + b⋅x❩", "x, y", [0, 10, 0.25]^2)
          drawVectorField("vectorField", "colour:#333333")

          flow ≔ computeFlowTrajectory("❨1 + a⋅r_1^2⋅r_2 − b⋅r_1 − r_1, -a⋅r_1^2⋅r_2 + b⋅r_1❩", "r", ❨1, 4❩, 0, 100, 0.01)
          drawLines("flow", "colour:gold")