Marey.Fields
0.7.0
dotnet add package Marey.Fields --version 0.7.0
NuGet\Install-Package Marey.Fields -Version 0.7.0
<PackageReference Include="Marey.Fields" Version="0.7.0" />
<PackageVersion Include="Marey.Fields" Version="0.7.0" />
<PackageReference Include="Marey.Fields" />
paket add Marey.Fields --version 0.7.0
#r "nuget: Marey.Fields, 0.7.0"
#:package Marey.Fields@0.7.0
#addin nuget:?package=Marey.Fields&version=0.7.0
#tool nuget:?package=Marey.Fields&version=0.7.0
Marey.Fields
Fields for Marey, a dimensionally-typed visualization system for F#. The gradient of a potential in volts over metres is a field in V/m, and the type says so.
#r "nuget: Marey.Fields"
#r "nuget: Marey.Backend.Svg"
open Marey
open Marey.UnitsOfMeasure
// Two line charges: a potential in volts, sampled over metres.
let phi (p: Vec2<m>) =
let d1 = Vec2.norm { X = p.X - 0.5<m>; Y = p.Y }
let d2 = Vec2.norm { X = p.X + 0.5<m>; Y = p.Y }
(log (float d2) - log (float d1)) * 1.0<V>
let xs = Grid.linear -2.0<m> 2.0<m> 81
let ys = Grid.linear -1.5<m> 1.5<m> 61
let potential = Field.sampleScalar xs ys phi // ScalarGrid<m, m, V>
let e = Field.grad potential // VectorGrid<m, m, V/m, V/m>
let rho = Field.div e // ScalarGrid<m, m, V/m²>
Field.heatmap U.metre U.metre Derived.volt potential
|> Chart.overlay (Field.contours U.metre U.metre potential)
|> Chart.render SvgBackend.render (Chart.size 640.0 420.0)
A phase space is a domain
A pendulum lives in (θ, ω): radians on one axis and radians per second on the other. A Flow
has a separate unit on each axis, and its grid's components are the rates of change.
let pendulum: Flow<rad, rad/s, s> = fun th om -> struct (om, -9.81<1/s^2> * sin (float th) * 1.0<rad>)
let flow = Field.sampleFlow (Grid.linear -3.0<rad> 3.0<rad> 61) (Grid.linear -6.0<rad/s> 6.0<rad/s> 61) pendulum
let d: ScalarGrid<rad, rad/s, 1/s> = Field.div flow // zero: phase-space area is conserved
// Field.curl flow // does not compile
The derived quantities say in their signatures which domains they exist on. div asks that ∂u/∂x
and ∂w/∂y share a unit, which a spatial field and a flow both satisfy. curl and laplacian ask
for one unit on both axes, so over a phase space they are compile errors. That is correct,
because ∂ω̇/∂θ and ∂θ̇/∂ω are in different units and their difference does not exist.
What is in it
- Grids.
ScalarGridandVectorGridon rectilinear nodes, from data or sampled from a function.Grid.linearandGrid.logspace the nodes evenly on a linear or a log axis. Bilinear reads do not extrapolate. A node that is not finite is kept, counted (missing) and not drawn. - Derivatives.
grad,div,curl,laplacianandjacobian, by three-point differences that are exact for a quadratic on any rectilinear grid and second-order otherwise. - Drawing.
Field.heatmap,Field.contoursandField.bands, with a colorbar in the field's unit. The picture is computed once the panel's scales are final, so a field lines up with every other layer on a linear or a log axis. Contour levels are the nice numbers the field's own range would be ticked at. Saddle cells are resolved by the asymptotic decider, and bands are filled even-odd, holes included. - Arrows.
Field.quiversizes each arrow by its magnitude through the quiver's own scale, because the arrows are in V/m and the axes in metres, and adds a key that says what one length means:2 kV·m⁻¹.Field.directionsdraws equal arrows for a phase space, where the two components share no unit and a length would mean nothing. Arrows follow the field on the panel, so they stay tangent to it on a log axis. - Streamlines.
Field.streamlinesdraws them evenly spaced on the page, a separation in pixels apart, so a phase portrait has its closed orbits around a centre and its separatrices through a saddle with nothing configured. They are integrated on the panel, so they stay the field's curves on a log axis. No randomness is involved, so the same field draws the same lines. - Line-integral convolution.
Field.licsmears a noise texture along the streamlines, so the flow shows at every pixel rather than along a chosen few lines.licBycolours it by magnitude. It is a raster at the plot area's resolution, with an oversample for print. Its noise is seeded, so a seed names one image. - Phase portraits.
Phase.fixedPointsfinds where a flow vanishes and classifies each point by its linearisation: saddle, node, focus or centre, with eigenvalues in1/'t.FixedPoint.describeprints one:saddle at (3.1416 rad, 0 rad·s⁻¹), λ = 3.1266, -3.1266 s⁻¹.Phase.portraitdraws the streamlines, the nullclines and the fixed points together. - Fields in motion. A field that changes with time is an
Anim<Figure>like any other, andFilm.ofFiguresrenders it. The colour scale and a quiver's arrow scale are held for the whole film, so a growing field is drawn growing.Chart.withColorDomainstates the range instead.
Links
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- FSharp.Core (>= 8.0.100)
- Marey.Core (>= 0.7.0)
- Marey.Plot (>= 0.7.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Marey.Fields:
| Package | Downloads |
|---|---|
|
Marey.Sim
Simulation for Marey: ODE integrators typed by units of measure (Euler, RK4, Dormand-Prince, velocity Verlet, leapfrog), trajectories that seek like any other animation, invariants, events and collisions, Poincare sections, pathlines and particles, finite-difference heat, wave and Poisson solvers, and fluids by stable fluids and lattice Boltzmann. |
GitHub repositories
This package is not used by any popular GitHub repositories.