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

Issue 1006 process space var #1020

Merged
merged 7 commits into from
May 27, 2020
Merged

Issue 1006 process space var #1020

merged 7 commits into from
May 27, 2020

Conversation

rtimms
Copy link
Contributor

@rtimms rtimms commented May 26, 2020

Description

Extend processed_variable to work in the case when len(t_sol)=1 and also makes it so you no longer need to pass t to the call in the cases where the variable is constant (doesn't depend on t or y) or when len(solution.t)=1 (e.g. algebraic models)

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes #1006 and #571

EDIT: Note that for variables discretised using finite elements (in y and z) the result returned by ProcessedVariable is transposed. This is consistent with other features, e.g. you can now do plt.pcolormesh(x,y,z) where z is some variable discretised with finite elements, whereas before you had to do plt.pcolormesh(x,y,np.transpose(z))

Type of change

Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #) - note reverse order of PR #s. If necessary, also add to the list of breaking changes.

  • New feature (non-breaking change which adds functionality)
  • Optimization (back-end change that speeds up the code)
  • Bug fix (non-breaking change which fixes an issue)

Key checklist:

  • No style issues: $ flake8
  • All tests pass: $ python run-tests.py --unit
  • The documentation builds: $ cd docs and then $ make clean; make html

You can run all three at once, using $ python run-tests.py --quick.

Further checks:

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

Copy link
Member

@valentinsulzer valentinsulzer left a comment

Choose a reason for hiding this comment

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

Looks good to me!

second_dim = second_dim[:, 0]
return interpolant(second_dim, first_dim)
else:
return interpolant(second_dim, first_dim)[0]
Copy link
Member

Choose a reason for hiding this comment

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

is there no way around the duplication of all these lines?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep, have made a function to take the interpolant and inputs and returns the result of the correct shape

second_dim = second_dim[:, 0]
return interpolant(first_dim, second_dim)[:, :, np.newaxis]
else:
return interpolant(first_dim, second_dim)
Copy link
Member

Choose a reason for hiding this comment

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

duplicated here

@rtimms rtimms merged commit bb5f204 into develop May 27, 2020
@rtimms rtimms deleted the issue-1006-process-space-var branch May 27, 2020 10:41
@rtimms rtimms mentioned this pull request Jun 14, 2020
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

process space-only variables
2 participants