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

Enhance cell editor #372

Merged
merged 12 commits into from
Nov 7, 2023
Merged

Enhance cell editor #372

merged 12 commits into from
Nov 7, 2023

Conversation

superstar54
Copy link
Member

@superstar54 superstar54 commented Oct 19, 2022

fixes #365

  • editing cell vectors directly.
  • cell transformation using a 3x4 transformation matrix.

Screenshot from 2022-10-19 08-03-10

@superstar54 superstar54 changed the title cell editor and transformation Enhance cell editor Oct 19, 2022
@unkcpz
Copy link
Member

unkcpz commented Oct 21, 2022

@superstar54 Thanks!
That "Cell vectors" and "Cell transformation" duplicate each other? Why not just keep the "Cell transformation"?
I would suggest adding instructions on how the matrix apply to the cell.

@superstar54
Copy link
Member Author

That "Cell vectors" and "Cell transformation" duplicate each other?

No. The "Cell vectors" are the cell itself (3x3 array). This enables the user to edit the cell directly, e.g. cell[2][2] += 10, which will add a vacuum in the z-direction, making a surface slab.
The "Cell transformation" transforms the cell by multiplying a (3x4) matrix.

I would suggest adding instructions on how the matrix apply to the cell.

Agree. I will add a tooltip for every button.

@unkcpz
Copy link
Member

unkcpz commented Oct 21, 2022

This enables the user to edit the cell directly, e.g. cell[2][2] += 10, which will add a vacuum in the z-direction, making a surface slab.

I see, thanks for the explanation, this is interesting. But don't you think it is mind-binding to set the off-diagonal for changing the cell in this way?

Agree. I will add a tooltip for every button.

I think that is not enough, my suggestion is for each matrix you keep the matrix on the left and on the right have a paragraph for the instruction, just like image

If the special symbols are hard to add, we can leave a text paragraph for future polish.

@superstar54
Copy link
Member Author

keep the matrix on the left and on the right have a paragraph for the instruction, just like

Will this make too much text on the GUI? I think a detailed explanation would be better put in the documentation.

@unkcpz
Copy link
Member

unkcpz commented Oct 21, 2022

Will this make too much text on the GUI? I think a detailed explanation would be better put in the documentation.

Emm... I can't agree with this, since the structure editor widget is default hidden and only shows when the user needs to use it. Meanwhile, we don't have documentation for QeApp, the application itself needs to be explainable.

After discussing in person, I now understand what the first matrix was used for, thanks!!
I am a VESTA user, so I also suggest to using the similar format for it which is the a,b,c, alpha, beta, gamma for cell setting.
Like:
image

@yakutovicha
Copy link
Member

yakutovicha commented Oct 21, 2022

@cpignedoli, could you please also have a look/test this PR? Just to make sure that it is implemented according to the user's needs.

@cpignedoli
Copy link
Member

Great idea @superstar54 , I had requests to implement a cell editor to create surfaces but still had no time to go in this direction.
Happy to see that things started.

I have a few comments from my experience with the simulation of surfaces:
typically I start from a problem defined, for example, as "simulate a molecule on a stepped ( e.g. Au(11 11 12) ) gold surface

Or simulate the S1(110) surface.

What I do is
1)I start from a bulk and scale the bulk to the desired lattice parameter (will I use the exp lattice parameter, or the one compatible with my DFT settings, or, am I studying a stressed crystal,..)

2)I enter the cleavage plane in the editor (e.g. 1, 1 ,1 or 11, 11, 12) and select a thickness for the slab (this is definitely not intuitive with high indexes, you need the graphical support..), and the amount of vacuum I want to add (can also be 0 if I want to simulate a bulk in "a surface cell" (e.g. to compute projected bulk band structures) and I click the "cleavage button"

  1. I adjust the thickness to the desired one

4)I "orient to standard" so that a1 coincides with x, a2 is in the xy plane (or I select a different standard if needed)

  1. At this point in many cases (e.g. (111) of a cubic crystal that would produce a hexagonal cell) I redefine the lattice as a linear combination of the primitive 2D vectors to obtain for example a rectangular cell (e.g. I typically work not with the hexagonal Au(111) but with (a1 +a2 , a2-a1) that is rectangular

6)I reorient to standard

  1. I replicate as desired

All of this without deriving myself the transformation matrices because for sure I would do hundreds of mistakes.

I hope my comments can be useful. We can also have a zoom call to see more examples

image (1)

@superstar54
Copy link
Member Author

@cpignedoli Thanks for the details. Very helpful.

1)I start from a bulk and scale the bulk to the desired lattice parameter (will I use the exp lattice parameter, or the one compatible with my DFT settings, or, am I studying a stressed crystal,..)

This PR tries to implement this (editing cell).

For the rest of the steps (building a surface slab), I think it's better to open a new PR.

I suggest using ase.build.surface to handle surface index, thickness, rectangular and so on.

@AndresOrtegaGuerrero
Copy link
Member

@yakutovicha Should we merge this PR , so the QE app can have the supercell and cell parameters editor?

@unkcpz
Copy link
Member

unkcpz commented Aug 3, 2023

Can anyone remind me what blocks this PR? Please add a comment.

@unkcpz unkcpz added this to the v2.1.0 milestone Oct 4, 2023
@unkcpz
Copy link
Member

unkcpz commented Oct 5, 2023

Hi @yakutovicha @cpignedoli, any update on this PR? Can we get only the supercell functionality merged and if there are more you want to add to this editor, we leave it to the future PRs?

@yakutovicha
Copy link
Member

Hi @yakutovicha @cpignedoli, any update on this PR? Can we get only the supercell functionality merged and if there are more you want to add to this editor, we leave it to the future PRs?

We briefly discussed this with PR @cpignedoli. We will give it a look this afternoon.

Copy link
Member

@cpignedoli cpignedoli 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 the editor is great but difficult to use for a user not expert. It should be merged but we should afterwards add few features:

  1. axes.. this is a viewer problem but becomes crucial here
  2. HTML help text with e.g. an example on how you get a 111 surface from a gold conventional cell (or, how do I get Au(788) )
  3. button to reset the matrix to 1 1 1
  4. the matrix should be probably reset when we import a new structure (but teh button above is enough)

There is one issue that in my opinion should be implemented before merging:
when changing the cell vectors I need the checkbox "scale coordiantes"

  • checkbox marked: I use this e.g. to change lattice parameter of my bulk (I uploaded a structure that has exp lattice parameter I want to scale it to PBE lattice parameter)
  • checkbox not marked: I want to set to 40 the z axis to add vacuum, the atomic positions should not be affected

@unkcpz
Copy link
Member

unkcpz commented Oct 16, 2023

thanks @cpignedoli.

@superstar54 please rebase this PR with the master branch and see if you can address the points mentioned by @cpignedoli. Thanks. As we discussed, this feature is better included in the next release.

@codecov
Copy link

codecov bot commented Oct 18, 2023

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (fc0e7e1) 85.76% compared to head (a1368c3) 85.82%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #372      +/-   ##
==========================================
+ Coverage   85.76%   85.82%   +0.06%     
==========================================
  Files          27       27              
  Lines        4553     4608      +55     
==========================================
+ Hits         3905     3955      +50     
- Misses        648      653       +5     
Flag Coverage Δ
python-3.10 85.82% <90.90%> (+0.06%) ⬆️
python-3.8 85.86% <90.90%> (+0.06%) ⬆️
python-3.9 85.86% <90.90%> (+0.06%) ⬆️

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

Files Coverage Δ
tests/test_structures.py 100.00% <100.00%> (ø)
aiidalab_widgets_base/structures.py 84.06% <89.36%> (+0.37%) ⬆️

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

@superstar54
Copy link
Member Author

Thanks @cpignedoli, for the suggestions. I have implemented:

  • button to reset the matrix to 1 1 1
  • the matrix should be probably reset when we import a new structure
  • checkbox to scale atoms positions
  • unit test

For the other two comments:

axes.. this is a viewer problem but becomes crucial here

I agree. We should address this in another PR.

HTML help text with e.g. an example on how you get a 111 surface from a gold conventional cell (or, how do I get Au(788) )

Note, that this PR is only used to edit the cell parameters, or make supercell, not to cut the surface.

cpignedoli
cpignedoli previously approved these changes Oct 18, 2023
@superstar54
Copy link
Member Author

superstar54 commented Nov 1, 2023

Hi @yakutovicha would you like to review this, or should I proceed with merging it?

@yakutovicha
Copy link
Member

yakutovicha commented Nov 2, 2023

Hi @yakutovicha would you like to review this, or should I proceed with merging it?

Let me give this PR a look today, just to be sure I didn't miss anything.

It will be quick, I hope 😄

@yakutovicha
Copy link
Member

I agree. We should address this in another PR.

I made an issue for this #532

@yakutovicha
Copy link
Member

In that

Note, that this PR is only used to edit the cell parameters, or make supercell, not to cut the surface.

I guess in this case we should modify the comment at the top, which says

Add the following features (#367, #365)

to prevent an accidental issue close

Copy link
Member

@yakutovicha yakutovicha left a comment

Choose a reason for hiding this comment

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

thanks @superstar54.

I requested a bunch of trivial changes, once done - good to go from my side 👍

aiidalab_widgets_base/structures.py Outdated Show resolved Hide resolved
Comment on lines 1033 to 1034
# reset transformation matrix
self.reset_cell_transformation_matrix()
Copy link
Member

@yakutovicha yakutovicha Nov 2, 2023

Choose a reason for hiding this comment

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

Suggested change
# reset transformation matrix
self.reset_cell_transformation_matrix()

I suggest not resetting the matrix automatically. The user will lose the information they entered.

I think it is safer to do that only when pressing the "Reset matrix" button.

Copy link
Member Author

Choose a reason for hiding this comment

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

I changed as you suggested.

aiidalab_widgets_base/structures.py Outdated Show resolved Hide resolved
aiidalab_widgets_base/structures.py Outdated Show resolved Hide resolved
aiidalab_widgets_base/structures.py Outdated Show resolved Hide resolved
aiidalab_widgets_base/structures.py Outdated Show resolved Hide resolved
aiidalab_widgets_base/structures.py Outdated Show resolved Hide resolved
@superstar54
Copy link
Member Author

Hi @yakutovicha , thanks for your review. I've incorporated the changes based on your suggestions.

Copy link
Member

@yakutovicha yakutovicha left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @superstar54!

@superstar54 superstar54 merged commit 1a28fe9 into master Nov 7, 2023
15 checks passed
@superstar54 superstar54 deleted the cell_transformation branch November 7, 2023 08:40
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.

Cell Editor: enable surface cleavage. support building supercell.
5 participants