Skip to content

Conversation

@cpignedoli
Copy link
Member

@cpignedoli cpignedoli commented Sep 17, 2025

connected to aiidalab/aiidalab-widgets-base#706
Constraints on x,y,z for each atom are stored in the ASE array 'fixed_atoms' .
image
image
The additional column is not present in case no constraints were specified

I need help (I would prefer in a separate PR), e.g. @edan-bainglass @superstar54, to add some warning logics:
If I load a structure that has constraints and I try to do phonons-related properties, I should get a warning. The warning can disappear only if 1)I remove the constraints, and 2) I do an additional geo-opt.

We should think about how to make this editor more general, including other types of constraints

@codecov
Copy link

codecov bot commented Sep 17, 2025

Codecov Report

❌ Patch coverage is 21.87500% with 125 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.29%. Comparing base (22e0b0e) to head (0b94534).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
src/aiidalab_qe/common/widgets.py 12.12% 116 Missing ⚠️
...qe/app/result/components/viewer/structure/model.py 68.00% 8 Missing ⚠️
src/aiidalab_qe/workflows/__init__.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1397      +/-   ##
==========================================
- Coverage   72.40%   71.29%   -1.12%     
==========================================
  Files         109      109              
  Lines        7317     7468     +151     
==========================================
+ Hits         5298     5324      +26     
- Misses       2019     2144     +125     
Flag Coverage Δ
python-3.11 71.26% <21.87%> (-1.12%) ⬇️
python-3.9 71.29% <21.87%> (-1.12%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

# Try to get fixed_atoms from AiiDA StructureData attributes
fixed_atoms = None
try:
fixed_atoms = self.structure.base.attributes.all['fixed_atoms']

Choose a reason for hiding this comment

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

Could you do something like fixed_atoms = self.structure.base.attributes.all.get('fixed_atoms', None) ?

chemical_symbols = ase_atoms.get_chemical_symbols()
tags = ase_atoms.get_tags()

def fmt_free(mask):

Choose a reason for hiding this comment

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

I think here, you can put a condition if mask is not an instance , mask = (0,0,0) and then you do return f"({' '.join('✓' if val else 'x' for val in mask)})"

self.input_selection = deepcopy(self.selection)


class AddingFixedAtomsEditor(ipw.VBox):

Choose a reason for hiding this comment

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

I think you could name this editor, as ConstraintEditor , so in the future new constraints as implemented

Copy link
Member Author

Choose a reason for hiding this comment

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

Done @AndresOrtegaGuerrero, thanks for the comments.
image
I have in mind how to modify the Editor to allow for other constraints, such as "distance", "torsion",..., but before we can do so, we would need such features implemented in the aiida plugin. Anyone willing to take the challenge @mbercx @superstar54 @edan-bainglass @AndresOrtegaGuerrero ?
We will also have to think about some warnings, since in QE, with symmetries, constraints can break the optimization.

@cpignedoli
Copy link
Member Author

Tables in the editor and in the result page now look like this:
image
image

@AndresOrtegaGuerrero
Copy link
Member

Should we finish reviewing this PR to merge it ? I think it could be of great help for heterojunctions

@cpignedoli
Copy link
Member Author

we do it at the conding week for sure

@superstar54
Copy link
Member

Hi @cpignedoli , sorry for the late response. Is this PR ready for review?

@cpignedoli
Copy link
Member Author

hi @superstar54 it was working but my plan was to revise it during the coding days

@cpignedoli cpignedoli changed the title Addign editor to fix atomic positions in x,y,z Addign editor to fix atomic positions in x,y,z and to add constraints Dec 1, 2025
Copy link
Member

@superstar54 superstar54 left a comment

Choose a reason for hiding this comment

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

Thanks for adding this feature!
I have a quick run on the app.

  • Change the tab name "Edit Constrains" to "Constrains" directly, and same for the other tabs, because they already in the "Edit structure" section.
  • If we also support other type of contrains, better to move current code in a subsection (or tab), e.g., "Fix positions"
  • Would be nice to have a table, with atom index, and contraints (x, y, z), which the user can edit/save/reset directly.
  • If the angle, and distance contrains are not supported by aiida-quantumespresso, we remove them in the text.
  • in my tests, the contrains are not shown in the table of the results panel.
  • add tests

@AndresOrtegaGuerrero
Copy link
Member

Thanks for adding this feature! I have a quick run on the app.

  • Change the tab name "Edit Constrains" to "Constrains" directly, and same for the other tabs, because they already in the "Edit structure" section.

Lets do that in another PR , and we keep this one only about the constraints.

  • If we also support other type of contrains, better to move current code in a subsection (or tab), e.g., "Fix positions"
  • Would be nice to have a table, with atom index, and contraints (x, y, z), which the user can edit/save/reset directly.
  • If the angle, and distance contrains are not supported by aiida-quantumespresso, we remove them in the text.
  • in my tests, the contrains are not shown in the table of the results panel.
  • add tests

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.

4 participants