Creating Interstitial Defect with InterstitialGenerator

Hi everyone,

I would like to learn about migration path of small atom like H or O by interstitial.
I need to generate some structures with interstitial sites - No specific interstitial locations. I tried
InterstitialGenerator in the pymatgen.analysis.defects.generators but I am not sure why it kept giving me error. The SubstitutionalGenerator worked fine
Here is an example of my script

from pymatgen.analysis.defects.generators import DefectGenerator, InterstitialGenerator
initial_struct = Structure.from_file('./Fe_Graphite_3x3_Clean/POSCAR')
inter_element = Element('C')
defect =InterstitialGenerator(initial_struct,'O')

here is the error “ValueError: min() arg is an empty sequence”
I looked up the code source and could not find where the error come from.
Does anyone have any suggestions?

Thank you for your time!

1 Like

Can you provide the full stack trace of the error, please?

I’m not sure what the error you’re referring to is, because the commands you provided are fine so long as your structure is sensible. That being said, you’re not using the interstitial generator properly. The interstitial generator is, unsurprisingly, a python generator. Meaning, you cannot assign defect = InterstitialGenerator(...) because InterstitialGenerator isn’t a defect; it generates defects when you iterate over it. This is because there are many possible interstitial sites in most structures.

If you want to convert it to a list of all interstitials, try the following:

from pymatgen.analysis.defects.generators import DefectGenerator, InterstitialGenerator
initial_struct = Structure.from_file('./Fe_Graphite_3x3_Clean/POSCAR')
inter_element = Element('C')
defects = [defect for defect in InterstitialGenerator(initial_struct, inter_element)]

Beyond this, if you still have that error, then we’ll need to see the stack trace.

1 Like

Hi @Nicholas_Winner and @Steven_Hartman ,

here is the error message

Can you share your POSCAR? If I run the script above with a standard Si structure, everything works fine. Either your structure is not correct, or the interstitial generator cannot find any sites. You can also try the VoronoiInterstitialGenerator located in the same module. It generally finds even more sites so it can be more conservative.

1 Like

Here is the POSCAR file
CONTCAR copy (Generated by CrystalMaker
1.00000000000000
7.3663628070856539 0.0000000000000000 0.0000000000000000
-3.6831811642302434 6.3794569099136131 0.0000000000000000
0.0000000000000000 0.0000000000000000 29.9589425495397279
C Fe
36 36
Selective dynamics
Direct
0.0088268138302968 0.0083412372444758 0.6620983168626901 T T T
0.0087971025225945 0.3417842793258462 0.6620869277158902 T T T
0.0088958877548647 0.6750865886603693 0.6619267913494259 T T T
0.3421184306082282 0.0085070231524889 0.6618981148817449 T T T
0.3422415704279869 0.3417748319660022 0.6619552771343413 T T T
0.3421395269557542 0.6749769989593359 0.6618917114029416 T T T
0.6756145014399739 0.0084914114842532 0.6619871661335761 T T T
0.6754632985160194 0.3416551293349119 0.6620616959972646 T T T
0.6754697007668551 0.6751122047355557 0.6618926388099968 T T T
0.0186750993289149 0.0089008525256155 0.7709139850203218 T T T
0.0186655669021977 0.3422501802655196 0.7709048931396433 T T T
0.0186918757538083 0.6755722001716520 0.7709030462026348 T T T
0.3520016775434319 0.0089376844313408 0.7709010871198365 T T T
0.3520232187474961 0.3422618219353884 0.7709012071044329 T T T
0.3520017983907308 0.6755850305322103 0.7708917228096731 T T T
0.6853625354232207 0.0089230596812552 0.7709094819819281 T T T
0.6853279686180580 0.3422459148472444 0.7709119346824881 T T T
0.6853367278401109 0.6755900309092810 0.7709067698509748 T T T
0.1199528816540015 0.2306335057738797 0.6605084069395480 T T T
0.1199117524127920 0.5639556921951313 0.6606223927257822 T T T
0.1199005641248801 0.8973039911708391 0.6606009250948076 T T T
0.4533010070604000 0.2306962787453292 0.6606287871481094 T T T
0.4533638384870627 0.5639955730179614 0.6604838358831372 T T T
0.4533501912171390 0.8973252669561225 0.6602135242819425 T T T
0.7866655080017524 0.2306474958795765 0.6607393384645307 T T T
0.7865877181009974 0.5639458214057154 0.6602910527326146 T T T
0.7866558465810182 0.8973265091242352 0.6605901053796954 T T T
0.2409015590205538 0.1200128396308073 0.7709110251983670 T T T
0.2408927018068807 0.4533446256861732 0.7709010044500797 T T T
0.2409026777856192 0.7866836427444185 0.7709006066000809 T T T
0.5742217369925517 0.1200250191569379 0.7709118879301681 T T T
0.5742341688103446 0.4533518579291677 0.7709103852105089 T T T
0.5742352450365013 0.7866918824156195 0.7709063183651970 T T T
0.9075688296572081 0.1200418164162923 0.7709179993478179 T T T
0.9075719715118071 0.4533629816049711 0.7709119266053771 T T T
0.9075539488464502 0.7867047592711840 0.7709168019137079 T T T
0.0079790566789200 0.0063901019510979 0.3978396178634540 F F F
0.0079773932136220 0.3397289620936164 0.3978431461380794 F F F
0.0079899508268184 0.6730649530990647 0.3978514978919563 F F F
0.3413141181520842 0.0063899142884694 0.3978339126313983 F F F
0.3412993261782091 0.3397284830158611 0.3978397283004469 F F F
0.3413115944663829 0.6730595010588871 0.3978470868953536 F F F
0.6746574114678339 0.0063904890005944 0.3978357475533301 F F F
0.6746496453429458 0.3397353947685602 0.3978399807093140 F F F
0.6746633506510022 0.6730738097472866 0.3978486101585972 F F F
0.2305742659540400 0.1177830289367066 0.4601482089269382 F F F
0.2305593735027429 0.4511102350052241 0.4601583041488126 F F F
0.2305778553043822 0.7844836260058727 0.4601576890436831 F F F
0.5638900989109175 0.1177751307452866 0.4601455758984159 F F F
0.5638908428076377 0.4511078721490378 0.4601571430860645 F F F
0.5639013725721256 0.7844803030418248 0.4601566825021379 F F F
0.8972271311889628 0.1177839251191415 0.4601507718925859 F F F
0.8972222352578356 0.4511071054531968 0.4601589581641363 F F F
0.8972416649283090 0.7844751238490346 0.4601597189705231 F F F
0.1187276882628661 0.2282243657179865 0.5265305682639133 T T T
0.1183031204874413 0.5623038160910158 0.5275531882959810 T T T
0.1205507274879123 0.8988920201124901 0.5274774324322471 T T T
0.4551535583982392 0.2314278249793209 0.5272072581117083 T T T
0.4527326497778027 0.5615815357095628 0.5278003044253500 T T T
0.4537129735953366 0.8982854018672414 0.5266808038467183 T T T
0.7856213345217737 0.2308372422992292 0.5275608469910096 T T T
0.7862414903025391 0.5629899338837221 0.5273256256818210 T T T
0.7883248240763396 0.8988293617756120 0.5279441208907137 T T T
0.0078324634785666 0.0067494476804803 0.5923067443295015 T T T
0.0096187278496917 0.3423730563363754 0.5923733659213241 T T T
0.0103476125652965 0.6759698451237371 0.5922752480410510 T T T
0.3416202603385848 0.0079581824162042 0.5922726650670652 T T T
0.3421307144102704 0.3421474950252509 0.5922770763981194 T T T
0.3423894726221695 0.6750535409195866 0.5924483419584052 T T T
0.6754893713115404 0.0076222065927092 0.5924298929100883 T T T
0.6758115192612817 0.3422043487346526 0.5924333736670375 T T T
0.6748282121135329 0.6755681599468826 0.5923757645950699 T T T
------------------------------------------------------------------------
Do you think that the Selective Dynamics tag was the one causing the error?
I tried the VoronoiInterstitialGenerator- it was running for like almost 2 hours and i had to stop it while substitutional took like 3 seconds. I am not familiar with the “Voronoi Interstitial” defect.

It is not the selective dynamics; you have quite an irregular system. Interstitial generating is not trivial and by default pymatgen searches for tetrahedral and octahedral environments as likely interstitial sites. The voronoi method is another possibility which grows in time complexity with the size of the cell.

I’d suggest trying to create a temporary structure without the vacuum space and try the generator on that to see if it can finish in time. Otherwise you’ll have to identify the sites manually and create the interstitial objects. Interstitial finding can be very tricky.

1 Like

Yup! I have an interface structure - Fe/graphite interface. I will give it a try

Thank you

1 Like

Hi,
Could you tell me how to obtain the doped structure after carrying out the code “defect =InterstitialGenerator(initial_struct,‘O’)”

Thanks,

Hi Nicholas,
Using the code you provided for ‘InterstitialGenerator’, I am receiving back this error which the class is not iterable. Any suggestion for this ?
Many thanks