Author Topic: SIA type (Si, C in SiC): Unexpected result with Selection Expression Modifier  (Read 246 times)

Xtof

  • Jr. Member
  • **
  • Posts: 62
Dear Alex and OVITO users,

After a cascade in SiC, I am trying to determine the number of SIAs of type Si (type 1) and those of type C (type 2).
To do so, I started from an ovitos script that was working fine for the Fe case and slightly modified it, changing the selection expression.
To select interstitials of type Si (1) this is what I did:

Code: [Select]

# import the cascade file
node = import_file(file_coord_final)
   
# Construct the modifier for Wigner Seitz analysis of SIA and V
ws_mod = WignerSeitzAnalysisModifier(eliminate_cell_deformation = True)

# Load the reference crystal   
ws_mod.reference.load(file_coord_init)
   
# Add the modifier to the modification pipeline
node.modifiers.append(ws_mod)

node.compute()


# Selection of interstitials of type Si (occupancy >=2, particle type = 1)
select_SIA_mod = SelectExpressionModifier(expression = 'Occupancy == 2 && Particle Type == 1')
node.modifiers.append(select_SIA_mod)
   
node.compute()



All this works but does not return the expected result. The total number of SIAs is 112. I checked it with the OVITO GUI. The number of SIAs of type Si is equal to 51. However, the script returns 112, that is, the total number of SIAs. It seems the condition 'Particle Type == 1' is not taken into account. But likely, I did something wrong.

Could you please give me a hand?

Many thanks in advance and best regards,
Christophe

Alexander Stukowski

  • Administrator
  • Sr. Member
  • *****
  • Posts: 370
Christoph,

I noticed a typo in your selection expression: "Occupancy == 2 && Particle Type == 1".
Within selection expressions, spaces in property names must always be omitted due to limitations of the expression parser. Like that: "ParticleType == 1"

However, I am surprised that you didn't see a corresponding error message. Normally, your final call to node.compute() should raise a Python exception in this situation. In the GUI, I am indeed seeing an error message being displayed: "Unexpected variable "Type" found at position 27" when using the same selection expression. I will need to check why the error is not getting raised in the Python script --after you confirmed that this is indeed the origin of your issue.

-Alex

Xtof

  • Jr. Member
  • **
  • Posts: 62
Hi Alex,

Thanks for the very prompt reply.

I confirm this is the origin of the issue. With 'ParticleType == 1' now it correctly gives SIA(Si) = 51. I am using the version 3.0.0 (dev) that you suggested me to try some time ago, the one that included parallelization for the WS analysis.

And I confirm it does not show any error message with Python.

I tried with previous version 2.8.0. In this case, Python does throw an error message if I use 'Particle Type == 1' with space, as you expected.

Xtof

Alexander Stukowski

  • Administrator
  • Sr. Member
  • *****
  • Posts: 370
I tested the Python script with the current development version of OVITO 3.0 and also an older version (dev52). In both cases I get the error message notifying me about the invalid selection expression, as expected.
Not sure why you don't get the error. Perhaps because you are using an even older development version, where the new data pipeline system wasn't completed yet. Please check if you get correct behavior with the current dev version, and let me know if not.

Xtof

  • Jr. Member
  • **
  • Posts: 62
It was with version dev39.
With the current dvpt version (dev105), it properly throws an error message when there is a space in 'Particle Type ==1' expression.

Xtof