Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The current API for the Dirichlet nodes is inconsistent and confusing (See #214). To simplify the API for users, I have created two functions that handle all the DC logic in a straightforward, intuitive, and consistent manner. Several variants are included for those looking to fully optimize these calls (though unless the model is changing DC activations nearly every
diffusion_dt
, I doubt they matter enough to be noticed). The old API, using verbsadd
,update
, andremove
remain so that we can preserve backwards compatibility. The new API usesfix
andunfix
.New API
To fix a substrate at a voxel, i.e., set a DC condition, users can call
where
new_value
is optional1.To unfix a substrate at a voxel:
In these and all cases that follow, passing in
int substrate_index
in place ofsubstrate_name
is allowed.Handling Boolean activations
The confusing part of the previous API was the inconsistency of updating the Booleans that tracked which
(voxel, substrate)
,voxel
, andsubstrate
had active DCs. This new proposed API handles these consistently:dirichlet_activation_vectors
maintains the lowest level detail wheredirichlet_activation_vectors[voxel_index][substrate_index]
indicates whether that substrate is has a DC at that voxeldirichlet_activation_vector
maintains whether a substrate has a DC anywher and is accessed bydirichlet_activation_vector[substrate_index]
voxel.is_Dirichlet
maintains whether any substrate has a DC at the given voxelConvenience API to (possibly) save time
Maintaining the above Boolean activation values can incur unnecessary computational expense if
fix
-ing orunfix
-ing many substrates/voxels at once. For users who wish to save even these scraps of time, the following are implemented to update the Boolean variables after accounting for all the changes:Fix with flexible value update
Anticipating users turning "back on" a DC, the
fix_...
calls do not require passing in a value. In this case, whatever value was indirichlet_value_vectors[voxel_index][substrate_index]
remains.Similarly, if fix multiple voxels at once with uniform DCs, just the one value can be passed:
All substrates in a voxel at once
To support changing all substrates in a voxel at once, the following three functions are provided:
Footnotes
It does not use an optional arg, but just has two implementations ↩