Author Topic: << script to decorate/functionalize nanotube >>  (Read 4005 times)

0 Members and 1 Guest are viewing this topic.

Offline Camps

  • Regular QuantumATK user
  • **
  • Posts: 6
  • Country: br
  • Reputation: 0
    • View Profile
<< script to decorate/functionalize nanotube >>
« on: September 16, 2021, 20:44 »
Hello,

I would like to know if there is any plugin or known script that permit the decoration or functionalization of nanostructures.

I am thinking in having a carbon nanotube, and randomly adding a functional group like -OH specifying the functionalization percentages, for example.

Regards,

Camps

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5576
  • Country: dk
  • Reputation: 96
    • View Profile
    • QuantumATK at Synopsys
Re: << script to decorate/functionalize nanotube >>
« Reply #1 on: September 21, 2021, 08:13 »
(I am having trouble with the formatting of this reply, it smashes all paragraphs together making it very hard to read, but I don't know how to avoid that... So sorry!) That is just a fun little programming exercise in the Builder! If you didn't try this already, you can open a Python console within the Builder by clicking the icon in the lower-left corner (it is blue and looks like >_). To prepare for this, copy/paste the following lines into the terminal:
Code: python
from NL.CommonConcepts.Configurations.Passivate import PassivationParameters
from NL.CommonConcepts.Configurations.PassivationUtilities import DEFAULT_H_LENGTH
This just sets up the imports we need. Second, assuming we just want the simple case of adding O-H to some carbon atoms in a CNT, define two objects which define the hybridization rules we need and the C-O and O-H bond lengths. It should be somewhat obvious how to modify this for other cases.
Code: python
co_passivation_parameters = PassivationParameters(
    default_h_length={Carbon:1.4},  # C-O bond length
    default_hybridization=4,    # SP3
    tag_map={'C': 'O_C'},
)
oh_passivation_parameters = PassivationParameters(
    default_h_length=DEFAULT_H_LENGTH,  # For O-H just use the default
    default_hybridization=2,    # SP
    tag_map={'O': 'H_O'},
)
Now we do the fun part! This part can be repeated and undone (Ctrl+Z x 3) as needed. First of all, obviously build a CNT, and make sure it has some decent length by repeating it in Z. Select the atoms you want to "decorate". Click and hold down the "Ctrl" key, or use a quick command:
Code: python
import random
N = len(configuration.elements())
selection = random.sample(list(range(N)), 4)
to randomly select 4 atoms (the 4 could of course also be random!). The next piece of code will passivate the selected atoms with H, however using a 1.4 Å bond length more suitable for C-O, then change the inserted H atoms to O, then passivate these with H.
Code: python
# How many atoms are we passivating?
n_pass = len(selection)
# Add an oxygen atom to selected atom(s) by pretending they should be SP3 coordinated
configuration = passivate(configuration, selection, co_passivation_parameters)

# Select the n_pass last inserted atom and change them to oxygen
N2 = len(configuration.elements())
selection = list(range(N2-n_pass,N2))
configuration = setElement(configuration, selection, Oxygen)

# Again select the inserted atoms (now O) and "passivate" them with H, using SP
selection = list(range(N2-n_pass,N2))
configuration = passivate(configuration, selection, co_passivation_parameters)
In principle this can of course be placed in a script instead, with the small change that you cannot just assign the magical keywords selection and configuration, you need to use a few more command. But doing this first in the Builder means you see exactly what goes on, and you can play with the commands and see what happens. After this, you should definitely run some geometry optimization, since they inserted atoms are kind of randomly placed (not really random, but certainly not in the perfect positions). It is probably sufficient with a force-field, using Coordinate Tools>Quick Optimizer. If you will use this function a lot, just click the red/blue icon to the right of the Console and click New snippet. You can insert all the code from above once and for all, save it, and then just re-run it to make a new selection and passivation each time, for the selected atoms (best to leave that part out, so you have control of the selected atoms, either manually or using a command). See picture attached! Now you will just have to select the atoms, and click "Run". Have fun, and do let us know how it works out!
« Last Edit: September 21, 2021, 08:31 by Anders Blom »

Offline Camps@Unifal

  • New QuantumATK user
  • *
  • Posts: 1
  • Country: br
  • Reputation: 0
    • View Profile
Re: << script to decorate/functionalize nanotube >>
« Reply #2 on: October 7, 2021, 20:53 »
Thank you very much!

I will follow the steps.

Camps