Repository navigation
Conversation
Better represent that the object passes is a class (and not an instance of it).
Allows to be more descriptive and catch better errors on the simulations that need specific mesh types.
Better represent that the object passes is a class (and not an instance of it).
|
Thanks for kicking this off Joe, and my apologies for not having time to jump in sooner on this idea. As I mentioned in our last SimPEG meeting, I am quite concerned about the potential confusion that could be introduced by collapsing the physical property (e.g. First, mappings are a challenging concept for people to grasp when they are first introduced to SimPEG. This is fair, it is an abstract concept. Right now, we can explain that if you set a Importantly, this implementation also means that what
I think this is dangerous. It is quite a common pattern to instantiate the simulation class and then access the mapping from there, e.g. and after the inversion This is fine in the current implementation, but if we combine the two, then this could lead to some unexpected behaviours and after the inversion This example is particularly dangerous if the mapping is a one-to-one mapping (e.g. like an exp map), because if the model is set on the simulation It is a common pattern amongst our users to access the mapping from the simulation. We even do this in our own tutorials (e.g. the SEG NS 2024 tutorial) So I don't think we can reasonably ask our users to unlearn the pattern of accessing the mapping from the simulation. I think we are much better of staying explicit when defining simulations and that Edit In looking more at the code, it wasn't clear to me what |
|
The functionality I'm proposing here is a little bit different than what you've interpreted it there. Basically these things would happen: If you set If you set The only difference between this and what we have now is that we would currently have to write: If you have not set a model then: If you haven't given I suspect that I do see your point about allowing users retrieve the assigned mapping to a simulation, for which this method would add a public method along the lines of One of the clunky things that I've found while writing The cleanest thing I like about this approach (which is something that I think we could change without doing this entire approach) Is that Also, something I'd love to tackle in the future is to really extend the power of |
|
Thinking on the interface a bit more overnight, and I think I've got something that could make the concept of What if instead we made mapping a physical property a method instead? And for a user retrieving it:
It would accomplish the major goals I have:
Another point of discussion would be what to do for a simulation's call signature. I'd be in favor of using a single argument to the simulation to handle both cases. Where: Which would allow us to make the simulation's call signature even clearer by promoting |
|
Closing in favor of working towards #1601 |

Summary
Allows physical properties to be directly set as maps
PR Checklist
expect style.
to a Pull Request
@simpeg/simpeg-developerswhen ready for review.Reference issue
More simulation cleanup
What does this implement/fix?
Currently in simpeg, we have two ways of interacting with a simulations physical properties.
sim.rhoto be an arraysim.rhoMapto be a mapping, which means that accessingsim.rhowill calculatesim.rhousing the mapping from the model to the physical property.I'm proposing unifying these two operations into only the physical property attribute itself. I.E. I want to be able to set
sim.rho = mapping, and have it be functionally the same as interaction 2) above.sim.rho = arrayor
sim.rho = mappingwhich allows us to then deprecate
sim.rhoMap.Additional information
A few details:
PhysicalPropertyclass is now a subclass ofproperty, allowing a more intuitive behavior than before.PhysicalPropertyis transformed into apropertyby thePhysicalPropertyMetametaclass. This meant, there was not a good way to modify a physical properties getter or setters (See the awkward hijacking of__getattr__in the BaseMagneticPDE simulation).PhysicalPropertyis not invertible, assigning amappingis disallowedPhysicalPropertyon a class-by-class basis.mappingand thederivfunction will not impact end users, (for developers there is still a way to access the map, and I think it's a cleaner method for when we must modify the behavior, e.g. the IP class.)The previous functionality of:
props.Mappingprops.Derivativeprops.Invertibleprops.Reciprocalis now unified into
props.PhysicalProperty