-
Notifications
You must be signed in to change notification settings - Fork 631
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
unit test and documentation for MaterialGrid #1508
Conversation
doc/docs/Python_User_Interface.md
Outdated
function defining an interface at $u(x)=\eta$ with a smoothing factor $\beta$ ($\beta=\infty$ gives an unsmoothed, | ||
discontinuous interface). The projection operator is `tanh(beta*eta) + tanh(beta*(x-eta))) / (tanh(beta*eta) + | ||
tanh(beta*(1-eta)))` involving the parameters `beta` ($\beta$: "smoothness" of the turn on) and `eta` ($\eta$: | ||
erosion/dilation). The level set provides a general approach for defining a *discontinuous* representation of the otherwise |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/representation of the otherwise/function from otherwise/
doc/docs/Python_User_Interface.md
Outdated
scheme with properties `subpixel_maxeval` and `subpixel_tol` which can be specified using the [`Simulation`](#Simulation) | ||
constructor. | ||
|
||
Grids which are symmetric (e.g., mirror, rotation) must be explicitly defined. This requires overlapping a given |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/This requires/One way to implement this is by/
doc/docs/Python_User_Interface.md
Outdated
constructor. | ||
|
||
Grids which are symmetric (e.g., mirror, rotation) must be explicitly defined. This requires overlapping a given | ||
`MaterialGrid` object with a symmetrized copy of itself. In this case, the overlapping grid points are combined using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the case of spatially overlapping MaterialGrid
objects (with no intervening objects), any overlapping points are computed using
doc/docs/Python_User_Interface.md
Outdated
|
||
Grids which are symmetric (e.g., mirror, rotation) must be explicitly defined. This requires overlapping a given | ||
`MaterialGrid` object with a symmetrized copy of itself. In this case, the overlapping grid points are combined using | ||
the method `grid_type` which is one of `"U_MIN"` (minimum of two grid values), `"U_PROD"` (product), `"U_SUM"` (sum), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minimum of the overlapping grid values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
U_SUM is the mean, not the sum
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it should be renamed to U_MEAN
Creates a `MaterialGrid` object. | ||
|
||
The input are two materials `medium1` and `medium2` which are linearly interpolated at each grid point using | ||
a NumPy array `design_parameters` of size `grid_size` (a 3-tuple or `Vector3` of integers) with floating-point values in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe call it weights
and a "weight function"
python/tests/material_grid.py
Outdated
self.assertAlmostEqual(freq_ref, freq_matgrid[-1], 2) | ||
|
||
## verify that the relative error is decreasing with increasing resolution | ||
self.assertLess(abs(freq_matgrid[1]-freq_ref),abs(freq_matgrid[0]-freq_ref)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We really should check that it's less by some factor, say by a factor of 3 (ideally 4, but…)
* unit test and documentation for MaterialGrid * fixes and tweaks * more fixes * fix test
Adds a unit test and documentation to the User Interface for
MaterialGrid
.A test (
python/tests/material_grid.py
) was added in #1242 but it does not seem to actually be doing anything (other than verify that an instance of theMaterialGrid
object can be instantiated). The test added in this PR is based on the resonant mode calculation from #1500 which was later modified to use subpixel smoothing in #1503.Separately, it might be useful to rename the member variable
design_parameter
of theMaterialGrid
class to e.g.density_grid
to make it more general since usage of theMaterialGrid
does not necessarily always have to involve the adjoint solver.