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 ... 332 333 [334] 335 336 ... 363
4996
Alternatively, you can modify the script to not ask for the file name interactively, but just enter the VNL file name manually into the script before you run it. In this case you also need to hardcode the sample name into the script. See http://quantumwise.com/forum/index.php?topic=300.0 for a discussion on precisely this.

4997
That looks ok, although note the following:

  • It will be hard to converge the calculation above 1 V bias. I'd limit the voltage range to 0-1 V for now (this is just a test to learn, anyway, right?)
  • The variable "scf" is not initially defined in this code segment. Make sure to have a statement "scf = None" before these lines!
  • You will probably find this post on I-V curves interesting: http://quantumwise.com/forum/index.php?topic=302.0
  • Good luck and have fun! :)

4998
That's odd, if you followed it exactly it should converge in 70-80 steps which is below the default max = 100.

Perhaps you can attach the script you run, and we can check if some parameter is set wrong.

4999
General Questions and Answers / Re: ATKError: bad allocation
« on: July 31, 2009, 22:29 »
Normally one would suspect that the larger unit cell would be a problem for the supersized system, in terms of memory. But in this particular case I think the issue lies with the enormous k-points sampling. I doubt you need 40x40, probably 20x20 is just as good, and uses much less memory, and runs much faster.

Note that for the supercell there is no real periodicity in the c-direction, and thus no need for k-point sampling there (1 point is enough). Therefore you have an easier time getting that system to fit in memory, but of course the results will not be the same due to the vacuum gap in the c-direction.

So, in summary, the problem is that you run out of memory due to the large k-point sampling.

5000
General Questions and Answers / Re: ATKError: bad allocation
« on: July 31, 2009, 12:04 »
I'm a bit confused... The structure you attached works, but the smaller structure does not work? If so, please attach the structure that doesn't work, it is more relevant to inspect that one...

5001
General Questions and Answers / Re: From crystalmaker to VNL
« on: July 31, 2009, 11:30 »
Trouble with this approach is that it only works when you know the answer. There is nothing that says that another problem will be "almost converged" after 50 iterations, just because the standard problem is, even using the same iteration mixing parameters etc. Each problem is unique, and the non-linear scf loop can take you on a very wild and wobbly ride in configuration space.

What you could do, is if you see from dRho and dEtot that, while you haven't reached precisely the accuracy you have set (say, 1e-5), these values stabilize at 1e-4 but have trouble getting down that last decimal, then you are, indeed, anyway "close to convergence".

5002
General Questions and Answers / Re: From crystalmaker to VNL
« on: July 31, 2009, 10:12 »
I still don't see what the criterion for judging whether the results are "good" or not would be... And I don't see how you could use the results obtained halfway through the SCF loop to judge whether it will converge or not.

5003
Right, 4 iterations per hour, that's quite normal for a Windows laptop. It will be MUCH faster on the cluster.

It might very well be converging. This is one of the most difficult systems around, and 70-80 iterations are typically needed (and that's the best we ever got this system to do, sometimes it needs 200...!).

Sure, the scripts are fully cross-platform compatible, so you can prepare the script in VNL on Windows, save it, run it on the cluster, and then reimport the VNL file back to Windows VNL and view the results. You can even bring over the NC file and do the second step analysis (transmission etc) on Windows, although you will probably want to run that on the cluster too, as it scales even better with the number of nodes.

5004
Parameters seem reasonable, but you are running a geometry optimization, is that what you really wanted?

Always try to converge the single point calculation (no optimization) first, to ensure that you have the right parameters for the quantum-chemical model. Then you can start relaxations, if necessary.

Note that each step in the optimization easily may take 10-12 hours, esp. if you run on a laptop or so. Multiply this by 10-20 steps of convergence for the geometry optimization, and you get quite a long time. That's why a system like this, esp. with so high k-point sampling (10x10) should be run on a cluster, in which case (precisely thanks to the k-points sampling in particular) will scale very nicely and perhaps run 10-20 times faster on, say, 16-32 nodes.

5005
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!

5006
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"?

5007
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!

5008
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".

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

5010
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.

Pages: 1 ... 332 333 [334] 335 336 ... 363