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

Pure heating/cooling does not work as expected #144

Closed
n-claes opened this issue May 26, 2023 · 1 comment · Fixed by #145 or #147
Closed

Pure heating/cooling does not work as expected #144

n-claes opened this issue May 26, 2023 · 1 comment · Fixed by #145 or #147
Labels
bug Something isn't working high priority Should be done asap
Milestone

Comments

@n-claes
Copy link
Owner

n-claes commented May 26, 2023

Issue description

PR #130 introduced decoupling of the heating and cooling terms. However, there are inconsistencies when the user supplies custom heating and/or cooling functions.

Assuming a user-specified cooling function $\Lambda(T)$ and heating function $H_0$ is always supplied (and cooling/heating is controlled through the parfile), then the following gives an overview:

cooling heating forced thermal balance what happens what should happen correct?
no  no - user-defined heating + cooling functions are set, but non-adiabatic matrix elements are not added. Spectrum is still adiabatic and correct. heating + cooling functions should return zero.
yes yes yes behaviour as expected. -
yes yes no behaviour as expected. -
yes no yes/no custom heating function is set and returns non-zero. heating function should return zero.
no yes yes/no heating function set but non-adiabatic elements are not added, spectrum is adiabatic  custom heating function should be used, system should be non-adiabatic, no thermal balance

Bug report

Minimal example for reproduction

module procedure user_defined_eq
    call settings%grid%set_geometry("Cartesian")
    call settings%grid%set_grid_boundaries(0.0_dp, 1.0_dp)
    k2 = 0.0_dp
    k3 = 1.0_dp

    call background%set_density_funcs(rho0_func=rho0)
    call background%set_temperature_funcs(T0_func=T0)
    call background%set_magnetic_3_funcs(B03_func=B03)

    call physics%set_heating_funcs(H_func=H0)
end procedure adiabatic_homo_eq

real(dp) function rho0()
    rho0 = 1.0_dp
end function rho0

real(dp) function T0()
    T0 = 1.0_dp
end function T0

real(dp) function B03()
    B03 = 1.0_dp
end function B03

real(dp) function H0()
    H0 = 2.0_dp
end function H0

Version info

  • Legolas version: 2.0.3
  • Pylbo version: 2.0.1
  • Python version: 3.11
@n-claes n-claes added the bug Something isn't working label May 26, 2023
@n-claes n-claes added this to the Legolas 2.1 milestone May 26, 2023
@n-claes
Copy link
Owner Author

n-claes commented May 26, 2023

Traced this down to the fact that users can still set custom physics functions in mod_physics, while Legolas checks for enabled physics when adding the matrix elements in mod_matrix_manager -- element blocks corresponding to disabled physics are simply skipped.

However, in the case of heating/cooling we only check if cooling is enabled, regardless of heating, which is also contained in mod_heatloss. Should be an easy fix:

  • do not allow setting custom functions if the corresponding settings instance is not enabled.
  • add an additional check for enabled heating when adding heatloss matrix elements.
  • ❗ add unit tests for these specific cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high priority Should be done asap
Projects
None yet
1 participant