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

Rewritten TS model with segmented laser geometry #219

Merged
merged 116 commits into from
Dec 22, 2022

Conversation

Mateasek
Copy link
Member

@Mateasek Mateasek commented Mar 17, 2020

I decided to do new PR, because at the end there were many changes:

  • laser geometry is now segmented cylinder as suggested by @mattngc. This propagated into handling of information between plasma, laser node, laser model and scattering model. This was neccessary to simplify handling of notifications, deletions and etc.
    • laser model and spectrum hold no plasma and laser reference. Their methods return requested properties (e.g. laser power) in laser node frame.
    • Laser material now obtains all the information from plasma, laser spectrum and laser model needed by the scattering model.
    • Scattering model works in the frame of reference of the laser node. Method for scattered spectrum calcullation must now get all the neccessary plasma and laser variables (e.g. Te, ne, directions, etc.)
  • laser models were rewritten and new added (uniform, bivariate and trivariate normal spatial distributions, Gaussian beam model). Lasers are now described by pulse energy and pulse temporal lengh, this is transformed to spatial power densities using given distributions.
  • laser spectrum power spectral density was corrected.

Unittests checking the following were added:

  • laser node
    • initialisation
    • propagation of notifications between laser model, laser spectrum, scattering model, laser geometry and laser material
    • position of the laser segments compared to the expected one
  • laser spectrum
    • initialisation and changes
    • normalisation of models
  • laser models
    • initialisation
    • polarisation direction
    • correct values of power for spatial points
    • integration of laser power over pulse spatial extent is compared to expected pulse energy
  • scattering model
    • scaterred spectrum traced by a ray is compared to expected values calculated by semi-analytical approach.

I hope that this time I minimised PEP8 incompatibilitity. If this state of the model is acceptable and won't be changed much, I will move to writting docstrings, documentation and examples:

  • Docstrings
  • Documentation
  • Examples

Segmented cylinder as laser geometry
rewritten laser model to correct power units
new laser model
laser material obtains all properties needed for scattering calculation
laser_spectrum and laser_model independent of plasma or laser
added tests for laser
@CnlPepper CnlPepper changed the base branch from development to feature/laser March 22, 2020 01:06
@CnlPepper
Copy link
Member

CnlPepper commented Mar 22, 2020

I'm going to propose we merge this into a feature branch first, so we can make a few tweaks before the merge into development.

@CnlPepper
Copy link
Member

CnlPepper commented Mar 22, 2020

This PR is looking a lot better and a lot cleaner. I see there are potentially some areas of improvement in the notification/change handling. I should be able to address that after merge if necessary, provided I'm sure of the original intentions. There are a few things I'd tweak. The material does seem a little over complicated. Some of the properties on the material should really be on the laser etc... if you compare the laser material with the beam material, that is really as complex as it should be.

@mattngc mattngc linked an issue Mar 30, 2020 that may be closed by this pull request
@mattngc mattngc requested a review from CnlPepper March 30, 2020 18:18
Laser material simplified. Most of the calculations moved to the scattering model. Caches of plasma and laser transforms
ScatteringModel got reference to the plasma and laser_model to provide values for the scattering calculations
ScatteringModel changed to LaserEmissionModel
Model manager handling emission models added to laser
Propagation of changes and notifications changed to be more like the beam model.
@Mateasek
Copy link
Member Author

I have simplified the material to be closer to the beam material as suggested by @CnlPepper. The code was moved to the scattering emission calculation. I have inspired myself in the beam model and simplified the notifications.

What should be the next step? Should I remove the draft flag so it is merged to the feature branch?

@CnlPepper
Copy link
Member

I think we should get it in a feature branch and do any final iterations there. I'm going to do a quick check over now.

@CnlPepper
Copy link
Member

I've added some comments to the existing review.

@Mateasek Mateasek marked this pull request as ready for review June 1, 2020 13:47
Segmented cylinder as laser geometry
rewritten laser model to correct power units
new laser model
laser material obtains all properties needed for scattering calculation
laser_spectrum and laser_model independent of plasma or laser
added tests for laser
Laser material simplified. Most of the calculations moved to the scattering model. Caches of plasma and laser transforms
ScatteringModel got reference to the plasma and laser_model to provide values for the scattering calculations
ScatteringModel changed to LaserEmissionModel
Model manager handling emission models added to laser
Propagation of changes and notifications changed to be more like the beam model.
@CnlPepper
Copy link
Member

Hey @Mateasek I see you marked this as ready for review, however there are some outstanding queries above.

cherab/core/laser/material.pyx Outdated Show resolved Hide resolved
cherab/core/laser/material.pyx Outdated Show resolved Hide resolved
cherab/core/laser/material.pyx Outdated Show resolved Hide resolved
cherab/core/laser/models/math_functions.pyx Outdated Show resolved Hide resolved
cherab/core/laser/node.pyx Outdated Show resolved Hide resolved
cherab/core/laser/scattering.pxd Outdated Show resolved Hide resolved
cherab/core/laser/models/model.pyx Outdated Show resolved Hide resolved
cherab/core/laser/scattering.pyx Outdated Show resolved Hide resolved
cherab/core/laser/node.pyx Outdated Show resolved Hide resolved
cherab/core/laser/node.pyx Show resolved Hide resolved
Copy link
Member

@vsnever vsnever left a comment

Choose a reason for hiding this comment

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

Hi @Mateasek,

This is a very important new feature. As far as I know, the Thomson scattering synthetic diagnostic is in great demand at ITER. Thanks a lot for this!

The comments are many but all the issues are minor.
Also, could you please update the changelog?

cherab/core/laser/__init__.py Outdated Show resolved Hide resolved
cherab/core/laser/laserspectrum.pxd Outdated Show resolved Hide resolved
cherab/core/laser/laserspectrum.pyx Outdated Show resolved Hide resolved
cherab/core/laser/profile.pyx Outdated Show resolved Hide resolved
cherab/core/laser/laserspectrum.pyx Outdated Show resolved Hide resolved
demos/laser/model_seldenmatoba.py Show resolved Hide resolved
demos/laser/thomson_scattering.py Outdated Show resolved Hide resolved
demos/laser/thomson_scattering.py Outdated Show resolved Hide resolved
demos/laser/thomson_scattering.py Outdated Show resolved Hide resolved
demos/laser/thomson_scattering.py Show resolved Hide resolved
There is currently no need to keep laser reference n LaserProfile. This
was a leftover from version, where some laser properties were in Laser
In LaserSpectrum class
from laser._plasma to laser.plasma
Rebuilding segment primitives was separated from assigning materials to
segment primitives. Rebuilding primitives is now called only in needed
cases.

Added configure_geometry to laser_profile notifier
Fixed missing addition of _plasma_changed to plasma notifier

Changing integrator changes only integrators within materials
@Mateasek
Copy link
Member Author

Mateasek commented Sep 7, 2022

Thank you very much @vsnever for doing this very thorough review and for suggesting the improvements and spotting problems. In case of the minor suggestions I applied the suggestions and marked them as resolved. There are few regarding the notifications and rebuilding of the geometry and materials, which I left opened because the applied changes should be checked again. I would like to ask you to see if it is what you had in mind, thanks.

Copy link
Member

@vsnever vsnever left a comment

Choose a reason for hiding this comment

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

Thanks for fixing all the issues. Now everything looks fine, except for a couple of leftover attributes.

cherab/core/laser/profile.pxd Outdated Show resolved Hide resolved
cherab/core/model/laser/model.pxd Outdated Show resolved Hide resolved
Copy link
Member

@vsnever vsnever left a comment

Choose a reason for hiding this comment

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

Thanks @Mateasek, I'm happy with this PR.

@Mateasek Mateasek changed the base branch from feature/laser to development September 13, 2022 10:21
@Mateasek Mateasek changed the base branch from development to feature/laser October 31, 2022 08:19
@Mateasek Mateasek changed the base branch from feature/laser to development October 31, 2022 08:19
@jacklovell jacklovell merged commit a7caca2 into cherab:development Dec 22, 2022
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.

Add a basic Thomson Scattering model
5 participants