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

Infiltration models #190

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open

Conversation

hugary1995
Copy link
Collaborator

@hugary1995 hugary1995 commented Dec 18, 2024

  • Infiltration models
  • TensorFromTorchScript
  • New line search option

@hdt5kt feel free to edit the description of this PR.

@hugary1995 hugary1995 self-assigned this Dec 18, 2024
Copy link
Contributor

Copy link
Collaborator Author

@hugary1995 hugary1995 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 really great! I made a lot of minor comments... for starters.

void diagnose(std::vector<Diagnosis> &) const override;

protected:
virtual void update_forces() override;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Typicallyvirtual + override is considered redundant, because override by itself means the function is virtual. So:

Suggested change
virtual void update_forces() override;
void update_forces() override;

Copy link
Contributor

Choose a reason for hiding this comment

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

updated

Comment on lines 54 to 59
/**
* The value of the driving force, depending on `_control` this is either the prescribed strain or
* the prescribed stress.
*/
Scalar _driving_force;
VariableName _driving_force_name;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We used the name "driving force" because for solid mechanics, the force could either be strain or stress. But I suppose there is a more specific name for this, maybe something like "_inlet_mass_flow_rate"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We will also need doxygen documentation for most, if not all, members. They are the comments right above each member. There is a specific format for the comment, see eg https://www.doxygen.nl/manual/docblocks.html

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Also the variable name could be const, i.e.

Scalar _driving_force;
const VariableName _driving_force_name;

See also https://isocpp.org/wiki/faq/const-correctness

Copy link
Contributor

Choose a reason for hiding this comment

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

updated

LiquidInfiltrationDriver::expected_options()
{
OptionSet options = TransientDriver::expected_options();
options.doc() = "Driver for Liquid Infiltration Process";
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Suggested change
options.doc() = "Driver for Liquid Infiltration Process";
options.doc() = "Driver for the liquid infiltration process";

Copy link
Contributor

Choose a reason for hiding this comment

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

updated

OptionSet options = TransientDriver::expected_options();
options.doc() = "Driver for Liquid Infiltration Process";

options.set<CrossRef<torch::Tensor>>("prescribed_liquid_inlet_rate");
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Suggested change
options.set<CrossRef<torch::Tensor>>("prescribed_liquid_inlet_rate");
options.set<CrossRef<Scalar>>("prescribed_liquid_inlet_rate");

Copy link
Contributor

Choose a reason for hiding this comment

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

updated

Comment on lines 38 to 39
options.set("prescribed_liquid_inlet_rate").doc() =
"Liquid saturate rate (mol/V) introducted to the RVE at the inlet";
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe say this rate has units of molar mass per volume. "mol/V" might be a misleading. Also I don't think we should mention "RVE" in particular, because the driver could work for any infiltration model, not just ones derived from an RVE.

Copy link
Contributor

Choose a reason for hiding this comment

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

Updated. Fixed for all other files as well.

src/neml2/tensors/user_tensors/FromTorchScript.cxx Outdated Show resolved Hide resolved
}

neml_assert(found, "No buffer named '", tensor_name, "' in file ", fname);
t = t.to(torch::kFloat64);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We should try not to hard-code the dtype to be float64.

Copy link
Contributor

Choose a reason for hiding this comment

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

So we can issue a comments/ errors to the user to make sure they get the correct dtype?

{
OptionSet options = FromTorchScript::expected_options();

options.set<Size>("batch_dim") = -1;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Why default to -1?

Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like when people provided the tensors, I don't think they have a specific batch dimension in mind. I could change it to {}.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We don't need to check in this file, do we?

Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking using this file as an example to show how TorchScript can be used to generate files as user input tensors. Might be helpful or we can add this code as an example in the documentation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If we reuse most of the code from regression_solid_mechanics, we should think about how to reduce code duplication.

@hugary1995 hugary1995 changed the title first clean version of liquid infiltration, with addin fromtorchscrip… Infiltration models Jan 3, 2025
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