some usability scripts

1,386 views
Skip to first unread message

Muftah Al-Mahdawi

unread,
Jul 16, 2015, 2:07:26 AM7/16/15
to vampir...@googlegroups.com
Dear all,
I am attaching few python scripts, one (gen_nbrs.py) for generating neighbours interactions portion of ucf file from atoms positions. Atom positions in a cubic unit cell can be generated by cif2cell tool http://cif2cell.sourceforge.net/ .
The second is to load atomic configuration and spin files for further post-processing (load_cfg.py), with an example for averaging at each step (step_average_example.py).
The third is for converting cfg files to vtk files for viewing in paraview or mayavi2. It uses evtk module (https://bitbucket.org/pauloh/pyevtk)
Please note that they depend on numpy to work.
They were not throughly tested, and I believe that others can come up with better scripts, but they can be used as starting points.

I suggest that saving output in hdf files is more efficient than ascii files for post-processing, but the developers probably have their reasons for doing so.

Best wishes,
Miftah

    
gen_nbrs_example.py
load_cfg.py
step_average_example.py
cfg2vtk.py

richard....@gmail.com

unread,
Jul 19, 2015, 5:59:42 PM7/19/15
to vampir...@googlegroups.com, mift...@gmail.com
Dear Miftah,

Thanks very much for these utilities - these are great additions to assist with the post processing of data. I am also working on a new config file code which will support multiple formats, initially binary and text, but later others such as hdf should be easily implementable.

All the best,

Richard

Muftah Al-Mahdawi

unread,
Jul 21, 2015, 11:58:29 PM7/21/15
to vampir...@googlegroups.com
Dear Richard,
First of all, thanks for the code, you provided us a silver bullet. I am looking forward for the binary format. But hdf is platform independent with a lot of software out there to utilize it.

Dear all,
There was a mistake in the scripts that depend on load_cfg module. Instead of "import load_cfg" line, it should be "from load_cfg import *".
I attached the correct ones.

For advocacy, if numpy is compiled with MKL or ACML, numpy can utilize multi-threading and the full potential of the processor. So there is almost no performance hit by using python. Also, Paraview is capable of running complex visualizations with ease of use of GUI. So for the not-so-fans of C/C++ who are only interested in results of calculations, I recommend python+numpy+scipy+vtk+paraview for post-processing. Although this is completely subjective.
Best wishes,
Miftah
--
You received this message because you are subscribed to the Google Groups "Vampire Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vampire-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
=============================================================
Postdoctoral fellow,
Crossing-Correlation Spin Electronics Lab (Sahashi group).
Dept. of Electronic Engineering, Tohoku University.

Research Center for Rare Metal and Green Innovation (RaMGI),
468-1, Aza-Aoba, Aramaki, Aoba-ku, Sendai 980-8579, JAPAN.
Tel/Fax: +81-22-752-2172
=============================================================
cfg2vtk.py
step_average_example.py

Bipul Mahato

unread,
Nov 28, 2015, 8:06:52 PM11/28/15
to Vampire Users
Dear Muftah,
                while running cfg2vtk, I got the following error..what is the cause of that and how to get rid of the error? Please tell me.

command: python cfg2vtk.py
error:
Traceback (most recent call last):
  File "cfg2vtk.py", line 3, in <module>
    from load_cfg import *
ImportError: No module named load_cfg

Muftah Al-Mahdawi

unread,
Nov 29, 2015, 11:24:37 PM11/29/15
to vampir...@googlegroups.com
Dear Bipul,

load_cfg.py should be in the same folder as cfg2vtk.py. Do you have them like that?
Also, cfg2vtk should be run like vampire or cfg2pov, from the data folder. If it is not on a path found by python, you should call it by full path.
Example:
user@machine:~/vampire-data/some-system$ python ~/vampire/pyutility/cfg2vtk.py

Also, I forgot to mention that the for loop range should be changed to match totoal number of output snapshots.

Regards,
Muftah

Bipul Mahato

unread,
Jan 8, 2016, 7:54:13 PM1/8/16
to Vampire Users
Hi Muftah,
              I did what you mention here. load_cfg and step_average_example.py ran without error. but the cfg2vtk is showing an error. which is

vampire$ python cfg2vtk.py

1 coordination file(s) to be loaded
Defined number of atoms is 725904.
I found 725904 atoms.

step number: 00000000
Spin file has 1 materials(s)
1 spin file(s) to be loaded
Defined number of spins is 725904.
I found 725904 spins.


Traceback (most recent call last):
  File "cfg2vtk.py", line 14, in <module>
    pointsToVTK("./spins-{:08d}".format(i), cx, cy, cz, data = {"temperature" : temper, "field" : field, "spin": (sx,sy,sz)})
NameError: name 'temper' is not defined

Can you tell me why this "temper" is coming and how to fix it?

Muftah Al-Mahdawi

unread,
Jan 9, 2016, 1:11:49 AM1/9/16
to vampir...@googlegroups.com
Dear Bipul,
It seems I did couple of typos, my bad.
The corrected and updated scripts are attached.

Basically, there are two simple functions in load_cfg.py that load coord and spin files into numpy arrays. Then evtk module is used to write vtk files.

Best wishes
-- 
=============================================================
Postdoctoral fellow,
Crossing-Correlation Spin Electronics Lab (Sahashi group).
Dept. of Electronic Engineering, Tohoku University.

Research Center for Rare Metal and Green Innovation (RaMGI),
468-1, Aza-Aoba, Aramaki, Aoba-ku, Sendai 980-8579, JAPAN.
Mobile: +81-90-2988-1403
[in] jp.linkedin.com/in/mahdawi
=============================================================
cfg2vtk.py
gen_nbrs_example.py
load_cfg.py
step_average_example.py

Bipul Mahato

unread,
Feb 18, 2016, 8:03:09 PM2/18/16
to Vampire Users
Thanks a lot.

Bipul Mahato

unread,
Feb 18, 2016, 8:07:06 PM2/18/16
to Vampire Users
Dear Muftah,
                  I converted the .cfg files to .vtu. Now I try to see the images. what command do you use to see those? I am trying it for a long time. Please, reply.


On Wednesday, 15 July 2015 23:07:26 UTC-7, Muftah Al-Mahdawi wrote:

Muftah Al-Mahdawi

unread,
Feb 18, 2016, 8:19:07 PM2/18/16
to vampir...@googlegroups.com
--
You received this message because you are subscribed to the Google Groups "Vampire Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vampire-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
=============================================================
Postdoctoral fellow,
Crossing-Correlation Spin Electronics Lab (Sahashi group).
Dept. of Electronic Engineering, Tohoku University.

Research Center for Rare Metal and Green Innovation (RaMGI),
468-1, Aza-Aoba, Aramaki, Aoba-ku, Sendai 980-0845, JAPAN.
Mobile: +81-90-2988-1403
[in] jp.linkedin.com/in/mahdawi
=============================================================

Bipul Mahato

unread,
Mar 11, 2016, 2:46:58 PM3/11/16
to Vampire Users
Hi Dr. Muftah,
                   Thank you very much for the support you provided to do the post processings. I am interested in doing magnetization dynamics simulation. If you have input script for magnetization dynamics simulation, please, post. I was trying with time series program but could not get any magnetization precession. The input file script I used, is as following.

#------------------------------------------
# Creation attributes:
#------------------------------------------
create:crystal-structure=fcc
create:periodic-boundaries-x
create:periodic-boundaries-y
#------------------------------------------
# System Dimensions:
#------------------------------------------
dimensions:unit-cell-size = 3.524 !A
dimensions:system-size-x = 200 !A
dimensions:system-size-y = 200 !A
dimensions:system-size-z = 42 !A
#------------------------------------------
# Material Files:
#------------------------------------------
material:file=NiFe.mat
#------------------------------------------
# Simulation attributes:
#------------------------------------------
sim:program=time-series
sim:integrator=llg-heun
sim:applied-field-strength=2 !T
sim:applied-field-unit-vector=(0,0,1)
sim:temperature=300
sim:laser-pulse-power=1.6e22
sim:equilibration-time-steps=2
sim:time-steps-increment=1000
sim:total-time-steps=1500000
sim:time-step=1.0E-15
sim:dipole-field-update-rate=1000
#------------------------------------------
# Data output
#------------------------------------------
output:real-time
output:time-steps
output:applied-field-strength
output:magnetisation
output:material-magnetisation
output:mean-susceptibility
output:anisotropy-energy
output:surface-anisotropy-energy
output:magnetostatic-energy
#------------------------------------------
#Configuration
#------------------------------------------
config:atoms
config:atoms-output-rate=100

#-------------------------------------------
#Screen
#-------------------------------------------
screen:time-steps
screen:applied-field-strength
screen:magnetisation

Bipul Mahato

unread,
Mar 15, 2016, 5:15:44 PM3/15/16
to Vampire Users
Hi Muftah,
               I would also like to get help if you know how to know/see the data columns of the output file?

qq970...@gmail.com

unread,
Oct 16, 2018, 8:05:37 AM10/16/18
to Vampire Users
Dear Miftah,
  Thank you very much for your utilities,it is very heipful, but i found there is an error in the python code (gen_nbrs_example.py). When it is calculating the distance between two atoms, the code was written like that 
"dist = linalg.norm( array( ( (x_dup[i]-x_dup[j])*ca, (y_dup[i]-y_dup[j])*cb, (z_dup[i]-z_dup[j])*cc ) ) )"
  I think the unit vectors should also be involved in it, so i modified it as below
"dist = linalg.norm((x_dup[i]-x_dup[j])*ca*ua + (y_dup[i]-y_dup[j])*cb*ub + (z_dup[i]-z_dup[j])*cc*uc )"

Best wishes
gen_nbrs_example-m.py
Reply all
Reply to author
Forward
Message has been deleted
0 new messages