Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Restructure AddSourceTermsMultiGroup #734

Merged
merged 65 commits into from
Sep 7, 2024
Merged

Conversation

chongchonghe
Copy link
Contributor

@chongchonghe chongchonghe commented Sep 4, 2024

Description

In this PR I attempt to make the AddSourceTermsMultiGroup function more structured.

Now, AddSourceTermsMultiGroup looks like this:

AddSourceTermsMultiGroup()
{
  // declare variables
  ...
    
  for outer loop {
    // declare variables
    ...
      
    // Compute the gas and radiation energy update. This also updates the opacities. When ite == 0, this also computes the work term.
    if (enable_dust_gas_thermal_coupling_model_) {
      updated_energy = SolveMatterRadiationEnergyExchange(..., &ComputeJacobianForGasAndDust, &ComputeDustTemperatureBateKeto);
    } else {
      updated_energy = SolveMatterRadiationEnergyExchange(..., &ComputeJacobianForGas, &ComputeDustTemperatureGasOnly);
    }
    
    // Compute radiation flux update
    ...
      
    // Deal with the work term.
    ...
  }
}

and this is the only place where enable_dust_gas_thermal_coupling_model_ is used.

Next, hopefully, I can implement more complex dust models and cooling/heating by defining new ComputeJacobian and new ComputeDustTemperature.

Related issues

N/A

Checklist

Before this pull request can be reviewed, all of these tasks should be completed. Denote completed tasks with an x inside the square brackets [ ] in the Markdown source below:

  • I have added a description (see above).
  • I have added a link to any related issues see (see above).
  • I have read the Contributing Guide.
  • I have added tests for any new physics that this PR adds to the code.
  • I have tested this PR on my local computer and all tests pass.
  • I have manually triggered the GPU tests with the magic comment /azp run.
  • I have requested a reviewer for this PR.

chongchonghe and others added 30 commits September 1, 2024 14:51
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@chongchonghe
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@chongchonghe chongchonghe changed the title Restructure: define ComputeJacobian Restructure AddSourceTermsMultiGroup Sep 5, 2024
@chongchonghe
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

Copy link
Collaborator

@BenWibking BenWibking left a comment

Choose a reason for hiding this comment

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

I think this is a good improvement and much better structured. I haven't gone through each line yet.

Did you intend to make the same changes to AddSourceTermsSingleGroup and AddSourceTermsMultiGroup? It looks like you've made similar changes, but I haven't compared them line-by-line.

There is a lot of commented-out code. Is it necessary to keep that? Otherwise, I think it would be a lot cleaner to just remove it.

@chongchonghe
Copy link
Contributor Author

Did you intend to make the same changes to AddSourceTermsSingleGroup and AddSourceTermsMultiGroup? It looks like you've made similar changes, but I haven't compared them line-by-line.

No, I did not do the same thing to AddSourceTermsSingleGroup and I don't intend to. I think AddSourceTermsSingleGroup is simple enough and I won't make much change to it in the future, so It's probably not worth doing it.

There is a lot of commented-out code. Is it necessary to keep that? Otherwise, I think it would be a lot cleaner to just remove it.

I see only one commented-out code (just before using SolveMatterRadiationEnergyExchange) and I meant to keep it for future reference.

@chongchonghe
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

Copy link
Collaborator

@BenWibking BenWibking left a comment

Choose a reason for hiding this comment

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

This looks good.

It would be useful to have the ordering of the variables used to define the Jacobian matrix listed in a comment next to the definition of JacobianResult.

Copy link

sonarqubecloud bot commented Sep 7, 2024

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Sep 7, 2024
@chongchonghe chongchonghe added this pull request to the merge queue Sep 7, 2024
Merged via the queue into development with commit 4a7057f Sep 7, 2024
20 checks passed
@chongchonghe chongchonghe deleted the chong/separate-v2.1 branch September 8, 2024 01:47
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
lgtm This PR has been approved by a maintainer size:XXL This PR changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants