Skip to content

Conversation

@cpinte
Copy link
Owner

@cpinte cpinte commented Sep 20, 2025

  • Parallelising gas density
  • Fixing OpenMP bugs
  • Fixing OpenMP gas mass
  • Cleaner power-law dust settling
  • Fixing typo
  • First try at splitting dust density

Type of PR:
Bug fix / new physics / modification to existing code / other

Description:
Give a short description of the change.

Testing:
Describe how you have tested the change

Did you run the botscheck that the code and comments follow the code of conduct? yes/no

Did you update relevant documentation in the docs directory? yes/no

@gemini-code-assist
Copy link

Summary of Changes

Hello @cpinte, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant refactoring of how dust density is managed and calculated throughout the simulation code. The primary change involves renaming the densite_pouss variable to dust_density and clarifying its physical interpretation, often requiring explicit multiplication by nbre_grains to represent total particle counts. This refactoring also includes memory optimizations for scenarios with a single dust grain size and updates to various density calculation, normalization, and radiative transfer routines to align with the new variable semantics. The changes aim to improve the accuracy and efficiency of dust density modeling, particularly in complex astrophysical environments.

Highlights

  • Dust Density Variable Refactoring: The variable densite_pouss has been consistently renamed to dust_density across the codebase, clarifying its role and improving code readability.
  • Explicit Grain Number Scaling: Calculations involving dust density now explicitly incorporate nbre_grains (number of grains) to correctly represent total particle density, especially when dust_density itself represents a density per grain or a normalized density.
  • Memory Optimization for Single Grain Size: The allocation of dust_density in src/mem.f90 has been optimized. When lvariable_dust is false (indicating a single grain size), dust_density is allocated with a dimension of 1 for grain types, reducing memory usage.
  • Refined Dust Settling and Normalization: The define_dust_density and normalize_dust_density subroutines in src/density.f90 have been updated to reflect the new dust_density interpretation and to handle normalization more accurately, particularly for variable dust populations and different settling types.
  • OpenMP Shared Variable Update: nbre_grains has been added to OpenMP shared clauses in src/SPH2mcfost.f90 and src/dust_prop.f90, ensuring correct parallel execution.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a significant and valuable refactoring by replacing densite_pouss with dust_density. This change effectively separates the spatial distribution of dust from its size distribution, which is a great improvement for code clarity and maintainability. The PR also includes performance enhancements and fixes related to OpenMP.

I've identified one critical bug in src/disk_physics.f90 where an incorrect loop index is used, which will lead to erroneous mass calculations. Additionally, there are some leftover debugging statements in src/density.f90 that should be removed before merging. Overall, this is a solid set of changes once these issues are addressed.

Comment on lines +44 to 59
! 1 grain -> 100 grains

! 0.37s -> 1.9s
write(*,*) "A"

call define_gas_density()
! 0.8s after OpenMP -> 2.4s
write(*,*) "B"

call define_dust_density()
! 1.4s -> 40.7s
write(*,*) "C"
!stop



Choose a reason for hiding this comment

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

medium

These debugging statements and comments should be removed before merging to keep the code clean and avoid unnecessary output.

- Correcting dust_density access: Replaced direct indexing with conditional logic or the p_k/p_l pointers in dust_prop.f90, thermal_emission.f90, output.f90, io_prodimo.f90, and read1d_models.f90.

- Updating OpenMP directives: Ensured thread safety for the new pointers in thermal_emission.f90.

- Fixing Normalization Logic: Corrected density.f90 to use volume integrals and properly handle grain size distributions when lvariable_dust is true.
@cpinte cpinte force-pushed the fast_density branch 3 times, most recently from aaff010 to d36e11a Compare January 10, 2026 22:57
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.

2 participants