Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python examples in docs need correct indentation to run #783

Open
jeffhammond opened this issue May 19, 2023 · 4 comments
Open

Python examples in docs need correct indentation to run #783

jeffhammond opened this issue May 19, 2023 · 4 comments
Assignees

Comments

@jeffhammond
Copy link
Collaborator

jeffhammond commented May 19, 2023

The intentation of https://nwchemgit.github.io/Python.html#scan-the-geometry-and-compute-the-energy-and-gradient is wrong and causes the input to run forever.

I think this is the correct indentation:

basis noprint; H library sto-3g; O library sto-3g; end

 python
 print ('   y     z     energy                gradient')
 print (' ----- ----- ---------- ------------------------------------')
 y = 1.2
 while y <= 1.61:
     z = 1.0
     while z <= 1.21:
         input_parse('''
           geometry noprint units atomic
             O 0   0   0
             H 0  %f -%f
             H 0 -%f -%f
           end
         ''' % (y, z, y, z))

         (energy,gradient) = task_gradient('scf')

         print (' %5.2f %5.2f %9.6f' % (y, z, energy)),
         i = 0
         while (i < len(gradient)):
             print ('%5.2f' % gradient[i]),
             i = i + 1
         print ('')
         z = z + 0.1    # MODIFIED
     y = y + 0.1        # MODIFIED
end

print none

task python

I need to figure out how to edit the documentation, which is the main reason I didn't fix this myself.

@jeffhammond
Copy link
Collaborator Author

jeffhammond commented May 19, 2023

If we are permitted to use Numpy in such examples, this is better:

basis noprint; H library sto-3g; O library sto-3g; end

python
    import numpy as np
    print ('   y     z     energy                gradient')
    print (' ----- ----- ---------- ------------------------------------')
    for y in np.arange(1.2,1.62,0.1):
        for z in np.arange(1.0,1.22,0.1):
            input_parse('''
              geometry noprint units atomic
                O 0   0   0
                H 0  %f -%f
                H 0 -%f -%f
              end
            ''' % (y, z, y, z))
    
            (energy,gradient) = task_gradient('scf')
    
            print (' %5.2f %5.2f %9.6f' % (y, z, energy)),
            for i in range(len(gradient)):
                print ('%5.2f' % gradient[i]),
            print ('')
end

print none

task python

@edoapra
Copy link
Collaborator

edoapra commented May 19, 2023

I need to figure out how to edit the documentation, which is the main reason I didn't fix this myself.

@jeffhammond
Scroll to the top of https://nwchemgit.github.io/Python.html,
click on the pencil icon to the top right,
this will open the wiki markdown page https://github.com/nwchemgit/nwchem-wiki/edit/master/Python.md

Once you have edited and committed your changes, the wiki source will be transformed to html and pushed to https://nwchemgit.github.io

@edoapra
Copy link
Collaborator

edoapra commented May 19, 2023

If we are permitted to use Numpy in such examples, this is better:

Sure, I would rather see simpler code.

@jeffhammond jeffhammond self-assigned this May 26, 2023
edoapra added a commit to nwchemgit/nwchem-wiki that referenced this issue Sep 5, 2023
@edoapra
Copy link
Collaborator

edoapra commented Oct 18, 2023

@jeffhammond I thin we could close this one after nwchemgit/nwchem-wiki@29b1d1c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants