Skip to content
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

Refactor TTim to compute per log t-interval #74

Closed
wants to merge 37 commits into from

Conversation

dbrakenhoff
Copy link
Collaborator

First attempt at refactoring TTim. Changes only done for Well Element and everything needed to compute the Theis solution.

If this looks okay, I'll implement the changes for all Elements.

- convert to dict: (self.tintervals, self.p)
- rename npint to nppar
- create separate compute_laplace_parameters_interval()
- add initialize_interval() method
- move laplace init to intialize()
- rename potential to potentialall
- rename potentialone to potential
- add solve_interval() method
- convert eigvec, eigval, coef, lab to dictionaries
- add initialize_interval() method
- convert term, flowcoef, dischargeinf and dischargeinflayers to dictionaries
- add initialize_interval method
rename potinfone to potinf
- convert self.parameters to dict
- add initialize_interval method
- modify setflowcoef()
- make it Abstract BaseClass
- force overloading of abstractmethods
- add initialize_interval()
- rename potential to potentialall
- add new potential method with t_int as additional argument
- rewrite potinflayers to use t_int
- npint -> nppar
- use t_int for accessing arrays from dictionary variables
- npint -> nppar
- use enumerate
@mbakker7
Copy link
Owner

mbakker7 commented Nov 1, 2024

Great start!
Couple of questions and things we should still do:

  1. We stick with dtype as "D" to specify a complex array. Is that indeed the recommended way to do this? Maybe also use dtype keyword here?
  2. In aquifer.py we differentiate between 'lea' and 'sem'. We need to document better what the diffference is.
  3. In element.py, potentialall function is for testing only, I presume. Should we add an starting underscore?
  4. Doc strings in element.py need to be updated to indicate correct size of returned array
  5. disvec and disvecinf functions in element.py need to be modified.
  6. In model.py, in initialize_interval I don't quite understand why we need to sort self.logtintervals?
  7. In model.py, # NOTE: this check no longer allows the right boundary of the time interval to be computed, which was allowed in the previous version of TTim. We need to discuss that.
  8. 'pot = pot * aq.eigvec[t_int][layers]' is much nicer than pot = np.sum(pot[:, np.newaxis, :, :] * aq.eigvec2[layers, :, jtime], 2), so I think we are on the right track!

fix divide by zero error
Still gotta clarify the lababs array
@dbrakenhoff
Copy link
Collaborator Author

  1. We stick with dtype as "D" to specify a complex array. Is that indeed the recommended way to do this? Maybe also use dtype keyword here?

Good idea, we can use dtype=complex instead.

  1. In element.py, potentialall function is for testing only, I presume. Should we add an starting underscore?

Yea this is a temporary thing, I wasn't sure yet if we still want to have a method that is maybe slightly more efficient in calculating the heads across all time-intervals. But good idea to add the underscore if it's only for testing.

  1. In model.py, in initialize_interval I don't quite understand why we need to sort self.logtintervals?

I thought it would be nice if logtintervals was always sorted, even after solving a separate intervals in a random order. So that's why.

  1. In model.py, # NOTE: this check no longer allows the right boundary of the time interval to be computed, which was allowed in the previous version of TTim. We need to discuss that.

This should be very simple to add back in. The way I programmed it now was to check whether t_int was in Model.logtintervals, but we can easily add back a comparison to the actual intervals, or add a special case for the final interval.

  1. 'pot = pot * aq.eigvec[t_int][layers]' is much nicer than pot = np.sum(pot[:, np.newaxis, :, :] * aq.eigvec2[layers, :, jtime], 2), so I think we are on the right track!

Agreed!

@mbakker7
Copy link
Owner

mbakker7 commented Nov 3, 2024

Fixed storing parameters in solve, and potinflayers, unitpotentiallayers.
Need to modify disinf and related functions in element.py
Write documentation on these functions.

Useful for testing
ttim/well.py Outdated Show resolved Hide resolved
ttim/well.py Outdated
def initialize_interval(self, t_int):
super().initialize_interval(t_int)
self.parameters[t_int] = np.zeros(
(self.model.ngvbc, self.nparam, self.model.nppar), "D"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dtype=complex

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now fixed. What is still undesirable is that now all Well classes have an initialize_interval function. Seems repetitive. Let's discuss.

@dbrakenhoff dbrakenhoff linked an issue Nov 7, 2024 that may be closed by this pull request
9 tasks
@mbakker7
Copy link
Owner

I think this PR can be closed and deleted as we have decided, for good reasons, that we are not going to do this.
The reason is that the computation of the head at a point in time may depend on many log-intervals, as the head is a superposition in time of a bunch of step responses (a new step response is computed after every change in boundary condition, e.g., a change in the discharge of a well or the head in a river).
What we do like in the near future is better documentation of the size and shape of matrices that are computed and multiplied at different parts in the code.

@mbakker7 mbakker7 closed this Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor internals to work with log time intervals
2 participants