### Author Topic: Compute & Visualization of temperature field  (Read 452 times)

#### WU-CHUNG-YEN

• Newbie
• Posts: 4
##### Compute & Visualization of temperature field
« on: November 23, 2018, 12:35:27 PM »
Dear users:
I want to use <Compute property> to calculate the temperature, and use compute ke/atom by lammps,

and I follow this fomula :
temp=2.0*(total Kinematic energy in Cutoff )/(NumNeighbors*Boltzmann constant)

but how do I use python to calculate total Kinematic energy in Cutoff

Thanks all

Best Regards

#### Constanze Kalcher

• Sr. Member
• Posts: 291
##### Re: Compute & Visualization of temperature field
« Reply #1 on: November 23, 2018, 01:33:30 PM »
Hi,

if I understand your question correctly you're asking how to use the Compute Property modifier in a python script?
If you have imported the per-atom kinetic energy with your data it will appear as particle property with the name you gave it in lammps. So you should have an extra column named e.g. "c_ke" in your dump file, right?

You can access that data in the ComputePropertyModifier.

Code: [Select]
`pipeline.modifiers.append(ComputePropertyModifier(    output_property = 'temp',    expressions = [ '2.0 * c_ke/(... )' ],    neighbor_mode = True,    neighbor_expressions = [ '2.0*c_ke /(...)'],    cutoff_radius = ....,))pipeline.compute()`where you would use your formula from above in the expression field and neighbor_expression field to calculate and average the property over all particles in the given cutoff. Note that you would have to divide by (NumNeighbors +1 ) though, since the central particle also counts.

http://ovito.org/manual_testing/python/modules/ovito_modifiers.html#ovito.modifiers.ComputePropertyModifier

~Constanze
« Last Edit: November 23, 2018, 02:24:33 PM by Constanze Kalcher »

#### WU-CHUNG-YEN

• Newbie
• Posts: 4
##### Re: Compute & Visualization of temperature field
« Reply #2 on: November 23, 2018, 03:51:55 PM »
Dear Constanze :
I use python scribe,
but it shows error,

#### Constanze Kalcher

• Sr. Member
• Posts: 291
##### Re: Compute & Visualization of temperature field
« Reply #3 on: November 23, 2018, 03:58:26 PM »
Hello,

note that what I explained above is not a python script modifier, it's how you would implement the Compute property modifier in a stand-alone python script which you execute from the terminal.
Please explain again what you're trying to calculate. If you want to average the per-atom values you calculate you don't need a python script modifier. The Compute property modifier already does that when you activate "Include Neighbor terms" (and divide by NumNeighbors +1 of course).

http://www.ovito.org/manual/particles.modifiers.compute_property.html

~Constanze
« Last Edit: November 23, 2018, 04:24:25 PM by Constanze Kalcher »

#### WU-CHUNG-YEN

• Newbie
• Posts: 4
##### Re: Compute & Visualization of temperature field
« Reply #4 on: November 23, 2018, 05:25:52 PM »
Dear Mr. Constanze :