Skip to content

DPGEN with constrained structures (new) - #892

Open
ShaneLogic wants to merge 1 commit into
deepmodeling:masterfrom
ShaneLogic:devel
Open

DPGEN with constrained structures (new)#892
ShaneLogic wants to merge 1 commit into
deepmodeling:masterfrom
ShaneLogic:devel

Conversation

@ShaneLogic

Copy link
Copy Markdown

To generate the constrained surface models proposed at discussion #877

Co-Authored-By: Cyanbeacon 86344464+Cyanbeacon@users.noreply.github.com

To generate the constrained surface models proposed at discussion [deepmodeling#877](deepmodeling#877)

Co-Authored-By: Cyanbeacon <86344464+Cyanbeacon@users.noreply.github.com>

@wanghan-iapcm wanghan-iapcm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you very much for the nice contribution. Could you please:

  • explanation how to use the atom constrain in the document
  • an illustrative example would be welcome
  • add UTs that make sure the code is working in an expected way.

@njzjz-bot njzjz-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict: Changes requested. The constrained-layer implementation can select or skip the wrong atomic layers and can fail for valid parameter combinations, potentially producing scientifically incorrect constraints. The PR also lacks documentation, examples, and unit tests and conflicts with master. I recommend reimplementing it against the current surf.py.

Note: The Codex quota is about to reset, so I am using the remaining tokens to review all open PRs in this repository.

Coding agent: Codex
Codex version: codex-cli 0.144.6
Model: gpt-5.6-sol
Reasoning effort: xhigh

Comment thread dpgen/data/surf.py
if from_poscar:
shutil.copy2( pos_in, pos_out)
shutil.copy2( pos_in, pos_out)
if "fix_layers" and "total_layers" in jdata:

@njzjz-bot njzjz-bot Aug 10, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[Blocking] if "fix_layers" and "total_layers" in jdata checks only total_layers, because the non-empty string is always truthy. Providing only total_layers enters layer() and then fails because fix_layers is absent; providing only fix_layers never writes Selective dynamics. The layer step also needs to apply outside the from_poscar branch. Otherwise generated surfaces have no flags while poscar_shuffle() reads coordinates as if a Selective line were present.

Comment thread dpgen/data/fix_layer.py
dis_small = cord_sort[0][2]
dis_big = cord_sort[-1][2]
max_dis = dis_big - dis_small
lay_space = max_dis / jdata["total_layers"]

@njzjz-bot njzjz-bot Aug 10, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[Blocking] max_dis / total_layers is off by one. For three layers at z=0,1,2 it computes a spacing of 2/3, so asking to fix the first two layers fixes only the first. At minimum, ideal equally spaced layers require total_layers - 1; a more robust implementation should cluster actual z coordinates with a tolerance to support relaxed or non-uniform surfaces. Add tests for one/two/multiple fixed layers, non-uniform layer spacing, and invalid parameter lengths.

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.

3 participants