Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Anders Blom

Pages: 1 ... 331 332 [333] 334 335 ... 361
4981
Please post output too. 40 hours - how many iterations are done within this time? Expect it to take about 70-80 iterations, this is a difficult system!

4982
General Questions and Answers / Re: From crystalmaker to VNL
« on: July 31, 2009, 09:07 »
Good that you solved the first part. Perhaps you could share the solution, others might benefit from it too.

About the second part, I interpret your question as:

"Will this procedure change the point to which the calculation converges? I.e., will it now converge to a different result than if it was left to run flat out all the way?"

In principle it will converge to a different point, since when you restore you lose the mixing history. However, if the convergence is stable, the difference should be negligible and just a matter of numerical accuracy. To improve the quality, you may in this case want to converge to a lower tolerance than the default (1e-5), just to be sure.

And, at the end of the day, to be really sure, you had better do a test to verify this, by simply letting it run, and then start over, interrupt it and restart, and compare the physical quantities (transmission etc).

I must however say that I don't really see how your approach would be useful... The calculations will never converge to anything wrong, unless it's a particular case of converging to zero charge (a common headache), but that usually happens within the first 5-6 iterations anyway. Otherwise, it's either a matter of converging or not converging, meaning running endless iterations. The latter is a problem, but the only way to discover it is to ... run the calculation until it converges. Or rather, inspect the convergence patterns (the dRho and dEtot values). If the scf loop is on a path to convergence, they will decrease steadily (usually after an initial period of wobbling and stabilizing slowly), or they will just stay at values like 1e+01 for a long time. But then you should just abort and retune the parameters.

Thus, I don't see any way by which you can inspect the results after, say, the 17th iteration, and judge their quality. I mean, what is the criterion by which you will say the results are "good"?

4983
I decided to publish the new module for relaxing a two-probe system in a new post. You can find it here: http://quantumwise.com/forum/index.php?topic=301.0

I hope it will enable you to extract the quantities you are interested in!

4984
Scripts, Tutorials and Applications / Relaxation under bias
« on: July 30, 2009, 13:13 »
As many have noticed, the latest version of ATK do not support geometry optimization of a two-probe system under bias. Here is a solution that enables this feature!

First of all, let us point out one thing. The reason the functionality to relax under bias was removed in the first place (or more specifically, the reason why two-probes are relaxed as equivalent bulk systems; that's why you cannot use bias, since a bulk system cannot be biased), was that we found out that there was an ambiguity regarding the configuration that minimized the forces vs. the configuration that minimized the total energy. That is, the force minimum and the energy minimum did not coincide.

Now, some experts maintain that this is to be expected. Since the two-probe boundary conditions are open, the total energy is not a well-defined quantity, one should rather probably use the free energy.

However, the forces as computed by ATK should still be correct. Therefore, it should be possible to use the force-based Steepest Descent method to relax a two-probe system, even under bias. Now, all we need to do to enable this feature, is to tweak ATK a little bit, and this is what the attached script does.

An example is provided to show you how to use it. It's just a simple Li-H2-Li system, with constraints applied so that only the hydrogen atoms can move. It should converge in 9 steps or so.

The following things need to be observed:

1) Only the Steepest Descent method is supported, for the reason mentioned above. The default in ATK is actually QuasiNewton, however if you forget to specify Steepest Descent the script will not complain, it will just silently use it anyway (and use the default "time_step").

For details on the relaxation method itself, and how to specify parameters to it, see http://quantumwise.com/documents/manuals/ATK-2008.10/ref.geometricoptimizationparameters.html and the example provided there.

2) Unlike the built-in method for relaxation, the new function calculateOptimizedTwoProbeGeometry() (note that the function has a different name, to separate it from the native one) returns BOTH the optimized geometry AND the final self-consistent object. This saves you the hassle of re-calculating the last step, as is otherwise necessary if you wish to follow up with some analysis in the same script.

3) A bug regarding verbosity level was fixed, so now the same verbosity level applies to the whole run (the native version reverts to zero after the first step).

4) This is not an officially released version of this functionality, so please use it a bit carefully, and at your own risk :)

5) There is also support for initializing the relaxation from an already converged density matrix (in the form of an SCF object). This can be used to boot-strap a finite bias relaxation from a converged calculation, e.g. for the same bias or a lower one.

6) Finally, I would recommend you place the module script CalculateOptimizedTwoProbeGeometry.py centrally in your ATK installation, i.e. in lib/python2.4/site-packages (on Linux, use lib/site-packages on Windows). That way it will work in parallel just as well as in serial, and you don't have to worry about setting the Python path etc.

Attached files are:
  • The module script
  • An example NanoLanguage script
  • The VNL file needed by the example

Comments, feedback etc is always welcome!

Update, after the original post: Added support for "initial_calculation".

4985
Please note the previous post was heavily modified after I posted it, so make sure to use the latest version of it!

4986
There are two ways. Either modify the script to contain the NC filename and sample explicitly, so you don't have to enter them when you run. Or, use "write" instead of "print". I will present both, although the "write" solution is probably best; there is a complete script for that at the end!

(Btw, do you really have a star * in the file name? It's a bad idea, it might screw things up here and there; better use "4x4x100" :) )

Method 1
Pipe the output to a file when you run it, like

Quote
atk extract_transmission_from_vnl_file.py > trans.dat

To modify the script for this is quite easy, just replace

Code
filename = raw_input('Please enter VNL file name: ')

by

Code
filename = "Au100-Au8-Au100_Transmission_4*4*100.vnl"

Then, replace

Code
sname = raw_input('Please enter sample name to extract (default=first sample): ')

by

Code
sname = ""

This only works if the sample we want is the first/only one in the file, but that is the case at hand, so we're good!

Method 2
Write a file from within the script, by replacing the "print" statements by "write" statements. This involved a few more lines to modify, so I'll just post the ready script.

Code
import zipfile, cPickle, sys

filename = raw_input('Please enter VNL file name: ')
try:
    f = zipfile.ZipFile(filename,'r')
except:
    print 'Unable to locate VNL file "%s"' % filename
    sys.exit(1)

# Restore the samples from the VNL file into a dict
samples = {}
for zinfo in f.infolist():
    s = f.read(zinfo.filename)
    try:
        obj = cPickle.loads(s)
        samples[obj.name()] = {}
        for h in obj.history():
            samples[obj.name()][h.name] = h.resultsample.properties()
    except:
        pass

print 'The following samples are present in this VNL file:'
print samples.keys()

sname = raw_input('Please enter sample name to extract (default=first sample): ')
if sname.strip()=="":
    data = samples[samples.keys()[0]]['NanoLanguage']
else:
    data = samples[sname]['NanoLanguage']   

print 'The following properties are present for this sample:'
print data.keys()

# Write the transmission data to a file
f = open("trans_"+filename+"_"+sname+".dat","w")
f.write('# Energy (eV)\tTotal transmission\n')
f.write('# ----------------------------------\n')

# Some older versions used "Transmission Spectrum" or "TransmissionSpectrum"
trans = data['Transmission Spectrum']
energies = trans.energy()._dataarray_
# Check for energy unit, if you want to be sure
# e_unit = t.energy().units()
T = trans.average_transmission()

# Write the transmission data to a file
for i in range(len(energies)):
    f.write('%g\t%g\n' % (energies[i],T[i]))
f.close()

Note that I use the VNL file name to label the output file, so in case you run several times, with different samples or VNL files, you will not overwrite the output files.

4987
Ok, this is because you (or whoever generated the script) made a customized label for this quantity when it was added to the VNL file. So, the only thing we need to change (after removing the "print" statement) is this line:

Code
trans = data['Transmission Spectrum Transmission Spectrum']

to

Code
trans = data['Transmission Spectrum T(E)']

Hope this works out for you now!

4988
Ok, time for some troubleshooting :)

You could just email me the VNL file, if it isn't too huge (usually it isn't unless you saved any 3D grids into it), and I can quickly figure it out. Or (if it is too big, or you just don't want to share it), you can insert a print statement

Code
print data.keys()

before the statement "trans = ...", and let us know the output, and we'll take it from there.

4989
Hmm, good news and bad news...

The script is not correctly set up, for many reasons.

First, although there is a loop over the voltages, each voltage uses the same checkpoint file, so each voltage overwrites the result of the previous one. To fix this, the line

Code
checkpoint_filename = 'C:/Users/617/Desktop/lih2li1.nc'

needs to be replaced by something like

Code
checkpoint_filename = 'C:/Users/617/Desktop/lih2li1_%g.nc' % voltage

This will make one checkpoint file for each bias.

So, unfortunately you have wasted some time computing the scf loop for each bias.

At the same time, the computation of the current is not part of the loop. Therefore, the current has only be computed for the last bias point, and thus you didn't waste any time on this part (that was the good news...).

By the way, I don't imagine you will be able to converge the calculation for as high bias as 5 V. You should probably limit the range, in the first run, from 0 to 1.5 V or so.

To get the current calculation into the loop, you should simply indent those lines one stop (4 spaces), and then also make sure each current is stored in the VNL file under a unique label. Thus, again, something like

Code
if processIsMaster(): file.addToSample(current, 'twoprobe_configuration', 'Current at %g V bias' % voltage)

Oh, and do pipe the output of the calculation to a log file, so you have the printed current values. Since these will be intermixed with all the output from the SCF loop, it might be a bit hard to locate them later. Therefore, I would change the line

Code
if processIsMaster(): nlPrint(current)

to something like

Code
if processIsMaster(): print "Voltage: %g V, Current: %g A" % (voltage.inUnitsOf(Volt), current.inUnitsOf(Ampere))

Then, later, you can "grep" for "Voltage" to get the values from the log file.

Actually, you may want to consider splitting the SCF part and the current calculation. That is, just run the loop over voltages but skip the current for now. Then, later, just restore all the checkpoint files and compute the current separately.

If you're ok making these changes by yourself, it will be a good exercise :-) But I suggest you post the script before you run it, and then we can verify that you will not be wasting your time again.

4990
A small correction: you can actually compute the forces under bias. However it is correct that you cannot use the built-in functionality to run a geometry optimization for a two-probe system under bias.

It is however possible to do "manually", and I have recently written such a module, which thus allows relaxation under bias, and thus facilitates computation of the quantities sought in the original question (more or less). I will post it here later today.

The authors used TranSIESTA, which at that time could be considered the "academic pre-cursor" to ATK. ATK has similar but not identical capabilities as TranSIESTA; most notably ATK is not based on SIESTA, it just uses the same LCAO method for the electronic structure.

4991
If you have the log file from the calculation, it should contain the transmission spectrum data as two columns (energy E, T(E)) somewhere towards the end.

If you don't have the log file any more (or, if you encounter the problem that there are too few decimals in the spectrum in the log file...), you can extract it from the VNL file using the method described here: http://quantumwise.com/forum/index.php?topic=3.0. Then, you can plot it in any software you prefer.

You may want to modify the script to load the VNL file internally (instead of prompting for it, interactively), and the same for the sample name (you know this from the Result Browser). Then, when you run the script, just pipe the output to a file, and you will have the spectrum in this file, ready for plotting in e.g. GNUPlot.

Hope you are able to figure this out, otherwise let us know if we need to post more detailed instructions.

4992
General Questions and Answers / Re: From crystalmaker to VNL
« on: July 30, 2009, 07:32 »
Can you attach the file, then we can have a look? It should be quite easy to write a small script to convert it (provided it's a text file).

4993
These files are provided in the file "transmission_scripts.zip" on the Tutorials page, just next to where to download the PDF file from (right-most column of the table). Please use the Monkhorst-Pack script from the ZIP file, as it's substantially updated compared to the older one in the Examples.

4994
General Questions and Answers / Re: Python Files in VNL
« on: July 29, 2009, 12:59 »
The concepts of surface layers are a bit different from the respective perspectives of the Python configuration and the Atomic Manipulator, so this is nothing to worry too much about.

If the geometry becomes distorted, it might however be an indication that it's not entirely correctly set up. In particular, pay special attention to the "alignment atoms". One way to check is to instead drop the Python file on the Nanosope. If it also looks weird there, then you can be quite sure there is some error in the setup.

4995
General Questions and Answers / Re: Python Files in VNL
« on: July 29, 2009, 10:00 »
If you have the geometry already defined in the Python script, there isn't really any need to save it as a VNL file, you can just drag the geometry directly to the NanoLanguage Scripter, as ZH mentions. Having the geometry in a VNL file can however be convenient if you want to reuse it several times, or import it into another script, without having to drag along the original Python code.

Thus, if you're anyway playing with the Python code, you can just add a few lines of code to generate a VNL file:

Code
f = VNLFile("/home/user/my_geometry.vnl")
f.addToSample(my_configuration,"My nice geometry")

(obviously you have to change the filename and variable name, and the label, to match your specific script and conditions).


Pages: 1 ... 331 332 [333] 334 335 ... 361