PrincetonUniversity / athena

Athena++ radiation GRMHD code and adaptive mesh refinement (AMR) framework
https://www.athena-astro.app
BSD 3-Clause "New" or "Revised" License
239 stars 129 forks source link

User-defined source functions cannot read parameters from athinput files #621

Closed smandal97 closed 2 months ago

smandal97 commented 2 months ago

Hi, I'm trying to write a source function for a stellar wind. Ideally, I'd like to store parameters for the wind (Mdot, v_wind etc.) in the athinput file. But I can't get the source function to access ParameterInput. Is there a way to have the source function access ParameterInput and therefore read parameters directly? Thanks!

tomidakn commented 2 months ago

You can define global variables in your problem generator file (protect it with a namespace if you wish), and set them in Mesh::InitUserMeshData or MeshBlock::InitUserMeshBlockData. If you do not like global variables, you can use user-defined data fields instead. Please take a look at the documentation. https://github.com/PrincetonUniversity/athena/wiki/Problem-Generators

In any case, accessing ParameterInput is not very fast, so we recommend to store the variable somewhere at the beginning of your simulation.