QuantumATK Forum

QuantumATK => General Questions and Answers => Topic started by: AsifShah on August 16, 2024, 21:55

Title: Setting different temperature for different regions
Post by: AsifShah on August 16, 2024, 21:55
Dear Admin,

How can one set a heating rate only for a specific tag of atoms? In QuantumATK by default heating rate is set for all atoms.
Title: Re: Setting different temperature for different regions
Post by: Anders Blom on August 27, 2024, 01:28
No, that is currently not implemented.
Title: Re: Setting different temperature for different regions
Post by: AsifShah on August 27, 2024, 07:27
Dear Anders Blom,
Thanks for your response.
I was able to do it manually using post_step_hook. Looks like post_step_hook is a nice way to do many things.
Title: Re: Setting different temperature for different regions
Post by: Anders Blom on August 31, 2024, 00:06
That's really nice, good job! Yes, the hooks are very useful.

May I ask what your application is, in case it's worthwhile that we implement more of a core-level support for this? And perhaps you can share your hook so the community can benefit from your clever solution!
Title: Re: Setting different temperature for different regions
Post by: AsifShah on August 31, 2024, 21:35
Dear Ander Bloms,
It's for simulating Joule's heating in a small region.
I would love to share but I am still improving upon the code. I am not able to maintain temperature properly. I used manual code in hook method but I was thinking if I could utilize velocity distribution from class MaxwellBoltzmannDistribution in QuantumATK. I have been trying to obtain velocities from this distribution but i run into errors.
Can you help me with that? I am trying to set velocities using this method for a configuration but it runs into error. Kindly help in this case.
Also, is there a direct way to extract say 10 random velocities from class MaxwellBoltzmannDistribution?

Code
# %% Molybdenite (1)

# Set up lattice
lattice = Hexagonal(3.1604*Angstrom, 12.295*Angstrom)

# Define elements
elements = [Molybdenum, Sulfur, Molybdenum]

# Define coordinates
fractional_coordinates = [[ 0.333333333333,  0.666666666667,  0.25          ],
                          [ 0.666666666667,  0.333333333333,  0.121         ],
                          [ 0.666666666667,  0.333333333333,  0.379         ]]

# Set up configuration
molybdenite_1 = BulkConfiguration(
    bravais_lattice=lattice,
    elements=elements,
    fractional_coordinates=fractional_coordinates,
    )
molybdenite_1_name = "molybdenite_1"

molybdenite_1.setVelocities(
    velocities=MaxwellBoltzmannDistribution(
        temperature=300*Kelvin
        )
    )



Title: Re: Setting different temperature for different regions
Post by: Anders Blom on September 5, 2024, 23:50
This is a special use case, normally the MaxwellBoltzmannDistribution is passed as an argument to the molecular dynamics algorithm, not the configuration itself. But it can be done, like so:

Code: python
mb = MaxwellBoltzmannDistribution(temperature=300*Kelvin)
mb._applyToConfiguration(molybdenite_1)

However, if you anyway intend to run MD on this, you don't need to set velocities on the atoms, just tell the MD algorithm to use the Maxwell Boltzmann distribution for initial velocities.
Title: Re: Setting different temperature for different regions
Post by: AsifShah on September 6, 2024, 22:32
Thanks a lot.