Skip to content

feat: well time step selector based on rates/bhp tables and clarify well rates logic #3427

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

Merged
merged 51 commits into from
Mar 11, 2025

Conversation

paveltomin
Copy link
Contributor

@paveltomin paveltomin commented Nov 6, 2024

Two things in this PR:

  1. Implement setNextDt in well solver which looks at all rates/bhp/status tables and makes sure time step is selected so that we honor table intervals. Can be enabled by timeStepFromTables flag in well solver.
  2. Change logic for well rates - currently inputted and outputted from t_n+dt (end of time step) - switch to t_n (beginning of time step) - this should be more consistent with lower interpolation method that is used and prevent grabbing "future" rate from tables and avoid weird behavior when time step cut can lead to shutting of wells.

@@ -377,4 +377,73 @@ WellControls const & WellSolverBase::getWellControls( WellElementSubRegion const
return this->getGroup< WellControls >( subRegion.getWellControlsName());
}

real64 WellSolverBase::setNextDt( real64 const & currentTime, const real64 & lastDt, geos::DomainPartition & domain )
Copy link
Contributor Author

Choose a reason for hiding this comment

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

main thing is in this function

Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed in test case that the writeCSV report is a little different ... Before ,first report was end of first DT, so no rates report at t=0, but there is report at last time, Now report starts at T=0, which is good, but no report at last timestep. So one needs to add dt to get the full picture, along with manually adding the line if in excel. Maybe on destruction or if component got end of sim call, the file record could be written..

Copy link
Contributor

Choose a reason for hiding this comment

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

Also how does this affect other output reporting...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i added time step size in the output, i think that should be enough to represent full picture
no effect on other output reporting is expected

@paveltomin paveltomin changed the title feat: well time step selector based on rates/bhp tables feat: well time step selector based on rates/bhp tables and clarify well rates logic Nov 6, 2024
@paveltomin

This comment was marked as resolved.

@@ -377,4 +377,73 @@ WellControls const & WellSolverBase::getWellControls( WellElementSubRegion const
return this->getGroup< WellControls >( subRegion.getWellControlsName());
}

real64 WellSolverBase::setNextDt( real64 const & currentTime, const real64 & lastDt, geos::DomainPartition & domain )
Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed in test case that the writeCSV report is a little different ... Before ,first report was end of first DT, so no rates report at t=0, but there is report at last time, Now report starts at T=0, which is good, but no report at last timestep. So one needs to add dt to get the full picture, along with manually adding the line if in excel. Maybe on destruction or if component got end of sim call, the file record could be written..

@@ -377,4 +377,73 @@ WellControls const & WellSolverBase::getWellControls( WellElementSubRegion const
return this->getGroup< WellControls >( subRegion.getWellControlsName());
}

real64 WellSolverBase::setNextDt( real64 const & currentTime, const real64 & lastDt, geos::DomainPartition & domain )
Copy link
Contributor

Choose a reason for hiding this comment

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

Also how does this affect other output reporting...

// - Nearest returns the value of the closest table vertex
// - Upper returns the value of the next table vertex
// - Lower returns the value of the previous table vertex
if( interpolationMethod == TableFunction::InterpolationType::Nearest )
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like there are 4 interpolation types... Linear, Nearest, Upper, Lower... Using the find method defaults to Upper ? then overridden if method is nearest or lower... Is there any chance of method being called with Linear

Copy link
Contributor Author

Choose a reason for hiding this comment

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

calling for Linear would not make much sense i think, should i add a check and throw an error for Linear?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

  GEOS_ASSERT_MSG( interpolationMethod != InterpolationType::Linear,
                   GEOS_FMT( "{}: TableFunction::getCoord should not be called with {} interpolation method",
                             getDataContext(), EnumStrings< InterpolationType >::toString( interpolationMethod )));

Copy link
Contributor

Choose a reason for hiding this comment

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

Changing BasedOnNewton tier changed to just IterNumber looks to support workflows beyond newton solvers? for better understanding. what is an example

Copy link
Contributor Author

Choose a reason for hiding this comment

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

simply the coupled sequential solver, it's not Newton iterations but the solver uses same logic for time step selection

@paveltomin
Copy link
Contributor Author

@paveltomin paveltomin removed the request for review from ryar9534 March 4, 2025 15:33
Comment on lines +64 to +67
this->registerWrapper( viewKeyStruct::timeStepFromTablesFlagString(), &m_timeStepFromTables ).
setApplyDefaultValue( 0 ).
setInputFlag( dataRepository::InputFlags::OPTIONAL ).
setDescription( "Choose time step to honor rates/bhp tables time intervals" );
Copy link
Collaborator

Choose a reason for hiding this comment

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

shouldn't this always be true? I am guessing we always want the timestep to respect the intervals, don't we?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I remember correctly, @dkachuma requested this behavior to be an option and I was hesitant to make it default

Copy link
Contributor

@MelReyCG MelReyCG left a comment

Choose a reason for hiding this comment

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

(Minor remarks)
Nice things in this PR!

Comment on lines 177 to 181
* @brief ...
* @param[in] input vector of input value
* @param[in] dim table dimension
* @param[in] interpolationMethod interpolation method
* @return coordinate value
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe unify the documentation with the other getCoord signature?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines +255 to +262
/**
* @brief Method to get coordinates
* @param input a scalar input
* @param dim the table dimension
* @param interpolationMethod the interpolation method
* @return the coordinate
*/
real64 getCoord( real64 const * const input, localIndex dim, InterpolationType interpolationMethod ) const;
Copy link
Contributor

@MelReyCG MelReyCG Mar 7, 2025

Choose a reason for hiding this comment

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

I think you should annotate the docs that this method is assuming createKernelWrapper() has been called (because it is based on the m_kernelWrapper data).
Maybe add an error in it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added
GEOS_ASSERT( dim >= 0 && dim < m_coordinates.size() );

@paveltomin paveltomin added ci: run CUDA builds Allows to triggers (costly) CUDA jobs ci: run integrated tests Allows to run the integrated tests in GEOS CI and removed flag: ready for review labels Mar 10, 2025
@paveltomin paveltomin merged commit 82aea9d into develop Mar 11, 2025
24 of 25 checks passed
@paveltomin paveltomin deleted the pt/well-dt branch March 11, 2025 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci: run CUDA builds Allows to triggers (costly) CUDA jobs ci: run integrated tests Allows to run the integrated tests in GEOS CI flag: requires rebaseline Requires rebaseline branch in integratedTests type: feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants