# Working with the included and custom geometries¶

For convenience, a number of common meta-atom geometries are included with OpenModes. The code below shows a list of those which are currently available

In [1]:
import openmodes
import os
import os.path as osp

os.listdir(openmodes.geometry_dir)

Out[1]:
['asymmetric_ring.geo',
'box.geo',
'canonical_spiral.geo',
'circle.geo',
'circled_cross.geo',
'closed_ring.geo',
'cross.geo',
'cylinder_rounded.geo',
'ellipsoid.geo',
'horseshoe_rect.geo',
'inverse_cross.geo',
'isosceles.geo',
'rectangle.geo',
'single.geo',
'sphere.geo',
'SRR.geo',
'torus.geo',
'v_antenna.geo']

## Geometric parameters¶

Most of these geometries are parameterised, so that you can specify certain dimensions when you load the file. For example, when loading a cross, we can specify the width and height (in metres). If we don't specify them, then default values will be used, which in most cases result in meta-atoms of around 10mm in size.

In [2]:
sim = openmodes.Simulation(notebook=True)
cross_filename = osp.join(openmodes.geometry_dir, "cross.geo")
mesh = sim.load_mesh(cross_filename, parameters = {'width': 4e-3, 'height': 20e-3}, mesh_tol=0.5e-3)
sim.place_part(mesh);


We can plot the resulting geometry. Try tweaking the parameters in the call to load_mesh, and you should be able to see the changes in the plot below. If the browser-based plot doesn't work for you, try one of the other plot types described in How to create 3D plots.

In [3]:
sim.plot_3d(output_format='webgl', wireframe=True)

Wireframe Format Arrow Length

## Mesh tolerance¶

An important additional option to play with is mesh_tol. This specifies how densely your object will be meshed. To see this in a 3D plot, pass the option wireframe=True, or click on the check-box.

The example above with the cross has a very dense mesh, which will unnecessarily slow down the computation. Note that the time taken for certain computations is $N^3$, where $N$ is approximately equal to the number of triangles in the mesh. We can see the number of triangles with the following command.

In [4]:
len(mesh.polygons)

Out[4]:
1288

In general, you should start working with a coarser mesh, to get some intial results. Once you have found the results that you want, re-run everything with increased mesh density until the results have converged sufficiently.

## Which geometry parameters can be modified?¶

Unless you wrote the geometry file yourself, you may not know the names of the parameters which can be tweaked. However, this is fairly easy to see if you inspect the geometry file, which is written in plain text.

In [5]:
with open(cross_filename) as infile:

// a flat cross

If (!Exists(width))
width = 1e-3;
EndIf

If (!Exists(height))
height = 10e-3;
EndIf

lc = 2e-3;

p = newp-1;

// Define the dipole
// define all points on the face
Point(p+1) = {-0.5*width, -0.5*height, 0, lc};
Point(p+2) = { 0.5*width, -0.5*height, 0, lc};
Point(p+3) = { 0.5*width, -0.5*width, 0, lc};
Point(p+4) = {0.5*height, -0.5*width, 0, lc};
Point(p+5) = {0.5*height, 0.5*width, 0, lc};
Point(p+6) = {0.5*width, 0.5*width, 0, lc};
Point(p+7) = {0.5*width, 0.5*height, 0, lc};
Point(p+8) = {-0.5*width, 0.5*height, 0, lc};
Point(p+9) = {-0.5*width, 0.5*width, 0, lc};
Point(p+10) = {-0.5*height, 0.5*width, 0, lc};
Point(p+11) = {-0.5*height, -0.5*width, 0, lc};
Point(p+12) = {-0.5*width, -0.5*width, 0, lc};

l = newl-1;

Line(l+1) = {1, 2};
Line(l+2) = {2, 3};
Line(l+3) = {3, 4};
Line(l+4) = {4, 5};
Line(l+5) = {5, 6};
Line(l+6) = {6, 7};
Line(l+7) = {7, 8};
Line(l+8) = {8, 9};
Line(l+9) = {9, 10};
Line(l+10) = {10, 11};
Line(l+11) = {11, 12};
Line(l+12) = {12, 1};

ll = newll;
Line Loop(ll) = {l+1, l+2, l+3, l+4, l+5, l+6, l+7, l+8, l+9, l+10, l+11, l+12};

s = news;
Plane Surface(s) = {ll};



In gmsh, it is possible to check if a parameter is defined with the exists command. So you can see that if width or height are not already defined, they will be given some default values. If they are specified in the parameters of load_mesh, then the given values will be used.