-
Notifications
You must be signed in to change notification settings - Fork 275
Parametrized physical properties #1601
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
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1601 +/- ##
==========================================
+ Coverage 86.52% 86.55% +0.02%
==========================================
Files 409 410 +1
Lines 52692 52984 +292
Branches 5000 5058 +58
==========================================
+ Hits 45594 45860 +266
- Misses 5678 5698 +20
- Partials 1420 1426 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Just use an "EM" Simulation
(For now) These should be changed to errors for futures
As suggested in their documentation
I think the new interface is coming together, here is a summary of the changes: New interfaceOn the constructor you can do:
Or changing it after creating a simulation:
When properties are
Added methodsThese public methods are added to the
DerivativesGetting the derivative of a property is now handled through a function, as opposed to a property, allowing us to (eventually) pass through multiplication vectors to the parametrizations.
Unless anyone has strong feelings otherwise, I'm in favor of keeping this private to keep the public API cleaner. I'll add more details in the future |
These are things that would be deprecated or removed with this PR. DeprecationsOn initialization
Attribute Assignment:
Attribute Access:
Removals
|
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.
Thanks for bringing this up again @jcapriot and sorry it took me so long to get back to this. I think this idea can work. I have just done a light pass to ask a few questions. Would you mind giving a demo again at an upcoming SimPEG meeting? It would be valuable to share this idea again with the group and get input from others. I think this could simplify things for users, but would appreciate chatting through implications for developers and people working to understand the code
@@ -66,7 +66,7 @@ def g(k): | |||
mtrue[mesh.cell_centers_x > 0.6] = 0 | |||
|
|||
# simpeg problem and survey | |||
prob = simulation.LinearSimulation(mesh, G=G, model_map=maps.IdentityMap()) | |||
prob = simulation.LinearSimulation(G=G, model_map=maps.IdentityMap()) |
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.
Is this change intended to be in this PR? I am not sure it is in this scope? or maybe I am missing something
@@ -112,12 +112,12 @@ def g(k): | |||
relatrive_error = 0.01 | |||
noise_floor = 0.0 | |||
|
|||
prob1 = simulation.LinearSimulation(mesh, G=G, model_map=wires.m1) | |||
prob1 = simulation.LinearSimulation(G=G, model_map=wires.m1) |
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.
similarly here, are these meant to be a part of this pr? it seems a bit different in scope?
val = recip.default | ||
# If it wasn't None, try to invert it. | ||
if val is not None: | ||
val = 1 / val |
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.
do we need a check that this is a scalar (or at least isotropic)? This wouldn't work if anisotropic
self.fset(obj, value) | ||
else: | ||
self._fset(obj, value) | ||
obj._remove_parametrization(self.name) |
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.
if I am following correctly, this would be hit if someone swapped out a mapping with a value or another mapping, is that right? If so, we might want to throw a warning? Changing something from an invertible parameter to not has some potentially involved implications
warnings.warn( | ||
f"Setting both `{prop1.name}` and `{prop2.name}` to None for `{type(self).__name__}`'s required " | ||
f"physical properties is deprecated behavior. This message will be changed to an error in simpeg " | ||
f"version X.X", | ||
FutureWarning, | ||
stacklevel=3, | ||
# f"`{type(self).__name__}` requires one of `{prop1.name}` or `{prop2.name}`" | ||
) |
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.
A question on warning / error handling, will the user first see that they need to change sigmaMap=mapping
to sigma=mapping
? If not, this warning might be confusing
warnings.warn( | ||
f"Setting `{cls_name}.{old_map}` directly is deprecated. Instead register a parametrization with `{cls_name}.parametrize('{new_name}')`", | ||
FutureWarning, |
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.
Can we also add that the user can set the mapping in the class instantiation via prop=mapping
. I think that is the behaviour that we will want to encourage (I suspect most people will find the transition from sigmaMap=mapping
--> sigma=mapping
much easier than going through the class.parameterize .....
approach
Summary
Implements a parametrized interface to
PhysicalProperties
PR Checklist
expect style.
to a Pull Request
@simpeg/simpeg-developers
when ready for review.Reference issue
What does this implement/fix?
Additional information
Continuing on from #1593