Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shapes for constructing geometries #8

Open
sp94 opened this issue Sep 22, 2020 · 0 comments
Open

Shapes for constructing geometries #8

sp94 opened this issue Sep 22, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@sp94
Copy link
Owner

sp94 commented Sep 22, 2020

Problem

Currently the geometry is defined by specifying an epf(x,y) function and a muf(x,y) function,

geometry = Geometry(epf, muf, ...)

This is straightforward for simple geometries but it becomes cumbersome if the geometry is made of multiple shapes.

We should introduce an additional interface for creating geometries,

geometry = Geometry(shapes, ...)

where shapes is a (nested) list of AbstractShape subtypes, eg

# accept nested list so we can use list comprehensions inside
shapes = [
    Circle(r,ep=4),
    [Rectangle(Lx,Ly,ep=3,origin=[n,0]) for n in -1:1]
]

and epf(x,y) and muf(x,y) are automatically generated from the flattened shapes, working in reverse order such that the last shape is on top.

Shapes

We should include some simple shapes and transforms for defining geometry, such as Ellipse or Rectangle. For example these shapes are available in meep:
https://meep.readthedocs.io/en/latest/Python_User_Interface/#geometricobject

We should also include a Background shape if the user wants to override the default values of ep=1 and mu=1, eg

shapes = [Circle(ep=4)]  # assumes background is ep=1, mu=1
shapes = [Background(ep=2), Circle(ep=4)]  # overrides default background

Shapes should default to ep=1, mu=1, origin=[0,0], angle=0, with dimensions (eg radius) as the positional arguments.

Transforms and piping

We can make use of Julia's function composition/piping for a nice interface:
https://docs.julialang.org/en/v1/manual/functions/#Function-composition-and-piping

Desired interface:

ellipses = [Ellipse(r1,r2,ep=11.7) |> translate(R,0) |> rotate(60n) for n in 1:6]
geometry = Geometry(ellipses, 1, a1, a2, d1, d2)

image

@sp94 sp94 added the enhancement New feature or request label Sep 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant