How to write structure to POSCAR file after replace by another atom?

Hi,

I would like to test effect of dopant by replacing specific species in the Structure by a list of atom.
I was able to put the list of dopants in for-loop but when I tried to write the structure to POSCAR, it kept giving me error " ‘NoneType’ object is not iterable" but when I place print (struct_test)' inside the loop, I was able to see the list of atom with a dopant. Here is an example of my code sub_atom = [‘Al’,‘Si’,‘Ti’,‘Mo’,‘Fe’] for i in sub_atom: struct_test.replace(0,i) struct = struct_test struct.to(filename=‘POSCAR_Al_1st_{}.vasp’.format(i))`
Does anyone have idea how to fix it?
Thank you for your time!

1 Like

Could you post the full stacktrace and the structure you’re using?

Hi,
Structure is an interface of Cr2O3 and Fe (111).
Here is the code I used
struct = Structure.from_file('./Interface/Cr2O3_Slab_Size/Cr_15/CONTCAR')
sub_atom = ['Fe','Si','Ti','Mo','Cr','Al']
for i in sub_atom:
struct.replace(0,i)
struct.to(fmt = 'poscar',filename = 'Interface/Cr2O3_Slab_Size/{}_Doped_Cr2O3_Cr_1st.vasp'.format(i))
I found out that if my structure is Selective Dynamic ( T T T) at the end of each position, this code did not run.
I am not sure how to fix this.

Thank you!

Can you post the full error output? Otherwise, we can’t tell what might have happened.

Hi shyamd,

Thank you for the respond!
I found that when I removed ‘Selective Dynamics’ tag and T T T and the end of each line in POSCAR, the for-loop work. Otherwise, it gave me this error " ‘NoneType’ object is not iterable"

Thanks,