Skip to content

Improvements to file generation methods, file templates, and a new universal templater function#48

Merged
LukeSeifert merged 16 commits intoarfc:mainfrom
ZoeRichter:templater
Feb 18, 2026
Merged

Improvements to file generation methods, file templates, and a new universal templater function#48
LukeSeifert merged 16 commits intoarfc:mainfrom
ZoeRichter:templater

Conversation

@ZoeRichter
Copy link
Copy Markdown
Collaborator

@ZoeRichter ZoeRichter commented Feb 6, 2026

Summary of changes

This PR is an improvement to the auto-generated file templates and templating methods used in Ghastly. It also sets up the template directory to be better organized by organizing templates for LAMMPS into a new lammps/ directory inside the templates folder.

I added a _templater() function, which renders a file using the provided dict and template. While updating the functions to use the generic _templater, I found some opportunities to simplify file generation, and as a result, some functions were no longer needed, and have been removed.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Associated Issues and PRs

Checklist for Reviewers

Reviewers should use this link to get to the
Review Checklist before they begin their review.

@ZoeRichter ZoeRichter self-assigned this Feb 6, 2026
@ZoeRichter ZoeRichter added Difficulty:2-Challenging This issue may be complex or require specialized skills. Priority:2-Normal This work is important and should be completed ASAP. Status:5-In Review This issue has been handled, and the solution is being reviewed. (probably as a PR) Type:Feature New feature or feature request labels Feb 6, 2026
@ZoeRichter
Copy link
Copy Markdown
Collaborator Author

I'm also going to @PeterCannon10 - I think this is a bit much for your first PR, but since you'll be working with Ghastly, I'm pinging you so you can take a look, if you would like.

PeterCannon10
PeterCannon10 previously approved these changes Feb 9, 2026
@PeterCannon10 PeterCannon10 self-requested a review February 9, 2026 14:25
@katyhuff katyhuff dismissed PeterCannon10’s stale review February 9, 2026 14:33

Peter wants to re-review -- accidental approve button mash.

Comment thread ghastly/templates/lammps/fillmain_template.txt
@ZoeRichter
Copy link
Copy Markdown
Collaborator Author

No worries - I'm also going to tag Megan, once I figure out her username. I'll require an approval from a more senior ARFC member before merging, so don't stress too much about having your review be perfect. If you end up only asking questions about how things work, that's fine by me. You can also always come in and ask questions in person, or in the undergrad slack.

@ZoeRichter
Copy link
Copy Markdown
Collaborator Author

Alright - I made a few tweaks to the templates themselves to make restarting sims much easier. This didn't change anything in the python side of things. These should be good for review. I'd like to get this pulled in before I present on 2/19 (Thursday evening).

Comment thread tests/f2_input.json
"zmax" : 0.0,
"zmin" : -0.1,
"r" : 0.1,
"open_bottom" : "",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why is open_bottom set as the empty string for the outlet of both the cylinder and cone input files when the other aspects of the geometry have open_bottom set to "open 1"?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I'm not seeing what you mean about a cone in this file, since the outlet is only a cylinder. But I can answer about the cylinder.

In LAMMPS, a region (such as a cone or cylinder) is assumed to be solid on all sides. If you want a particular side to allow particles to pass through it (so pebbles can flow) then you have to specify that when you define the region. The syntax for that is "open X', where X corresponds to which surface you want open (the numbers are defined in the LAMMPS documentation). For a cylinder, X=1 for the bottom, and X=2 for the top. Putting an empty string puts nothing, and leaves that surface solid.

The reason this particular surface is solid is because it's the bottom of the outlet, and I don't want the pebbles to fall out.

Comment thread ghastly/main.py
settle = ""
case _:
_write_settle_block("settle.txt", sim_block, reg_names)
settle = "include settle.txt"
Copy link
Copy Markdown

@PeterCannon10 PeterCannon10 Feb 16, 2026

Choose a reason for hiding this comment

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

What is there a large gap in settle = "include settle.txt"?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The gap is just to make sure the text matches the indentation level in the rest of the LAMMPS file - it's a style/readability thing, but it doesn't do anything beyond that.

Copy link
Copy Markdown
Contributor

@LukeSeifert LukeSeifert left a comment

Choose a reason for hiding this comment

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

Overall this looks good, the new template files clean things up a lot. I had a few comments on things, but generally I think there's only a few things that need minor changes.

Comment thread ghastly/templates/lammps/f1main_template.txt
Comment thread ghastly/templates/lammps/f2main_template.txt
Comment thread ghastly/templates/lammps/f2main_template.txt
Comment thread ghastly/templates/lammps/siminit_template.txt
Comment thread ghastly/templates/lammps/velreg_template.txt
Comment thread ghastly/main.py
Comment thread ghastly/main.py Outdated
Comment thread ghastly/main.py Outdated
Comment thread ghastly/main.py Outdated
Comment thread ghastly/main.py Outdated
@ZoeRichter
Copy link
Copy Markdown
Collaborator Author

I might make more small fixes here and there in the templates - I'll let you all know if it's a change to something other than the static portions of the templates.

Comment thread ghastly/main.py Outdated
ZoeRichter and others added 2 commits February 17, 2026 12:15
Co-authored-by: LukeSeifert <44068471+LukeSeifert@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@LukeSeifert LukeSeifert left a comment

Choose a reason for hiding this comment

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

The changes look good! There are still one or two comments that you haven't responded to yet, but I think this will be good to merge once you take a look at those and make an issue or two on some of the other things that don't need to be taken care of in this PR (like adding more documentation, naming conventions, restructuring the _pack_core crp argument).

Copy link
Copy Markdown
Contributor

@LukeSeifert LukeSeifert left a comment

Choose a reason for hiding this comment

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

LGTM

@LukeSeifert LukeSeifert merged commit 4049d02 into arfc:main Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Difficulty:2-Challenging This issue may be complex or require specialized skills. Priority:2-Normal This work is important and should be completed ASAP. Status:5-In Review This issue has been handled, and the solution is being reviewed. (probably as a PR) Type:Feature New feature or feature request

Projects

None yet

4 participants