bwvdnbro / CMacIonize

C++ Monte Carlo photoionization and radiation hydrodynamics code.
https://bwvdnbro.github.io/CMacIonize/
GNU Affero General Public License v3.0
23 stars 13 forks source link

Some puzzles about the initialization methods of photosource. #109

Open xiaowang119 opened 5 days ago

xiaowang119 commented 5 days ago

In my case, a laser beam is expected to radiate at a Polyethylene target. But two photosources was always found in initialization progress.

The first group: ContinuousPhotonSource ContinuousPhotonSourceSpectrum

And the second: PhotonSourceDistribution PhotonSourceSpectrum

How can i define a laser beam?

bwvdnbro commented 4 days ago

There are a number of parts to your question, but the short answer is: you will need to write some new C++ code to achieve what you want.

The code supports two types of photon sources: discrete sources, corresponding to the PhotonSourceDistribution and PhotonSourceSpectrum parameter blocks, and continuous sources, corresponding to the ContinuousPhotonSource and ContinousPhotonSourceSpectrum blocks. The first group is very particularly used for sources inside the simulation box and assumes (this is hard-coded) isotropically emitting point sources. The second type is more general and corresponds to an arbitrary model that generates photon packets with a certain starting position and direction. Historically, this was implemented to model an isotropic radiation field that falls in from outside the simulation box, but I think it could also be used to model a laser beam.

Practically, you will need to set type: None for the PhotonSourceDistribution in your parameter file, so that the model only uses the ContinousPhotonSource to generate photons. You then need to implement a C++ class that contains the logic for your laser beam model. This class should inherit from the existing ContinuousPhotonSource class in the code (you can look at DistantStarContinuousPhotonSource for an example implementation) and implement the appropriate functions to generate random photon packets. You then also need to register this class in ContinuousPhotonSourceFactory to make it available in the parameter file.

However, from your short description, I am not sure CMacIonize is really suitable for what you are trying to do. The code was written to model the ionization state of an interstellar medium irradiated by the light of stellar sources, and only contains atomic data relevant for that scenario. You will need to add a lot of additional physics to model a laser beam irradiating a polyethylene material. I would also like to point out that active development of the code stopped in 2021, so I cannot offer much support to help you in the process.

xiaowang119 commented 4 days ago

Thank you very much! Your suggestions are extremely helpful, and I believe they will greatly benefit me. If necessary, I will further modify the program according to my specific application scenarios. Thanks again.