JuliaGeometry / Contour.jl

Calculating contour curves for 2D scalar fields in Julia
Other
44 stars 13 forks source link

WIP: Support for curvilinear coordinates #16

Closed darwindarak closed 4 years ago

darwindarak commented 9 years ago

It almost works!

θ = linspace(0,2π,10)
R = linspace(1,3, 10)
ζ = Complex128[r*exp(im*ϕ) for ϕ in θ, r in R]
x, y, z = real(ζ), imag(ζ), abs(ζ)

so z has the form

10x10 Array{Float64,2}:
 1.0  1.22222  1.44444  1.66667  1.88889  2.11111  2.33333  2.55556  2.77778  3.0
 1.0  1.22222  1.44444  1.66667  1.88889  2.11111  2.33333  2.55556  2.77778  3.0
 1.0  1.22222  1.44444  1.66667  1.88889  2.11111  2.33333  2.55556  2.77778  3.0
 1.0  1.22222  1.44444  1.66667  1.88889  2.11111  2.33333  2.55556  2.77778  3.0
 1.0  1.22222  1.44444  1.66667  1.88889  2.11111  2.33333  2.55556  2.77778  3.0
 1.0  1.22222  1.44444  1.66667  1.88889  2.11111  2.33333  2.55556  2.77778  3.0
 1.0  1.22222  1.44444  1.66667  1.88889  2.11111  2.33333  2.55556  2.77778  3.0
 1.0  1.22222  1.44444  1.66667  1.88889  2.11111  2.33333  2.55556  2.77778  3.0
 1.0  1.22222  1.44444  1.66667  1.88889  2.11111  2.33333  2.55556  2.77778  3.0
 1.0  1.22222  1.44444  1.66667  1.88889  2.11111  2.33333  2.55556  2.77778  3.0

which would look like straight lines if plotted in rectangular coordinates. But if the matrices x and y that contain the coordinate points are passed in, we get

circles

There are still a few kinks to work out though. For example:

θ = linspace(0,2π,100);
R = linspace(1,2, 50);
ζ = Complex128[r*exp(im*ϕ) for ϕ in θ, r in R];
x, y = real(ζ), imag(ζ);
z = imag(ζ .+ conj(1./ζ));

results in

cylinder

coveralls commented 9 years ago

Coverage Status

Coverage remained the same when pulling ee1173fee956441e47b6d9283dac53a8c54b1a60 on dd/curvilinear_coords into 2d5ca7de9d36da63b31e1eb7cab83a0b21d15dea on master.

tomasaschan commented 9 years ago

Very cool! I have no idea what the quirks are about, but I'm sure you'll find it =)

I have a couple of concerns about argument types for some of these, but that should be quite easy to fix. I'll comment on the relevant code lines separately.

coveralls commented 9 years ago

Coverage Status

Coverage remained the same when pulling ef839045c09b3a0e010c1c97629896173b0f8d5d on dd/curvilinear_coords into 2d5ca7de9d36da63b31e1eb7cab83a0b21d15dea on master.

coveralls commented 9 years ago

Coverage Status

Coverage remained the same when pulling e048006c6a274e6c56c3c4896d8a781b308127a5 on dd/curvilinear_coords into 2d5ca7de9d36da63b31e1eb7cab83a0b21d15dea on master.

darwindarak commented 9 years ago

I think I fixed it, so now we can make plots like this:

cylinder

without having to do too many coordinate transforms.

coveralls commented 9 years ago

Coverage Status

Coverage remained the same when pulling 3b64d1997362d2a5b70d164e4e15f3a2dbabb606 on dd/curvilinear_coords into 2d5ca7de9d36da63b31e1eb7cab83a0b21d15dea on master.

tomasaschan commented 9 years ago

Nice!

Still needs documentation, though, even though these examples are a good starting point - I'd need a mathematical description of how to create x and y to understand how to do it for whatever system I'm working in.

darwindarak commented 9 years ago

Yeah, definitely. I'll add the documentation as soon as I can. There are also a few edge cases I want to test out.

SimonDanisch commented 4 years ago

@darwindarak, would be nice to merge this ;)

darwindarak commented 4 years ago

Just rebased on master branch and updated the syntax. @SimonDanisch I haven't used Julia in a while, do you mind taking a look to see if anything needs to be changed? Otherwise I'll merge once the tests go through.

sjkelly commented 4 years ago

This will be helpful to my lab mates. I say lets merge and work out the bugs.

edit: The code looks good!