10000 NICS_zz procedure doesn't work · Issue #3 · wongzit/pyAroma · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

NICS_zz procedure doesn't work #3

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

Open
zedo-heptulose opened this issue Nov 24, 2024 · 4 comments
Open

NICS_zz procedure doesn't work #3

zedo-heptulose opened this issue Nov 24, 2024 · 4 comments

Comments

@zedo-heptulose
Copy link

The feature for obtaining corrected NICS_zz for out-of-plane rings doesn't seem to work - when using this feature on a planar benzene ring, it yields a different value than the normal NICS_zz. Looking at the source code, it seems like the math isn't right. Could you take another look at this? Thanks

@wongzit
Copy link
Owner
wongzit commented Feb 28, 2025

I apologize for the delayed response. Could you please send me the output file? The results of NICS_zz seems to be working well for my outputs.

@zedo-heptulose
Copy link
Author

Apologies for the delay — I’ve been meaning to follow up for a while.

I ran some test calculations with benzene rotated at different angles relative to the $xy$ plane, and found the following two issues (I seem to have misplaced the log files, I'll try to recreate the procedure and send them to you soon).

The procedure for calculating NICS_perp for rings not aligned with the $xy$ plane gives outputs which are

  1. not rotation-invariant - rotating the input geometry results in a different NICS_perp value
  2. not the same as NICS_zz when the ring is already aligned to the $xy$ plane.

I propose the following change:
Instead of the currently implemented algorithm,

  1. Calculate the matrix $\mathbf{U}$ required for a change of basis to a coordinate system where the new z axis is the ring normal
  2. Apply the change of basis to the magnetic shielding tensor using the formula $\mathbf{U^{-1}\sigma{}U}$ (where $\mathbf{\sigma}$ is the magnetic shielding tensor)
  3. Take the zz component from this transformed tensor to obtain NICS_perp

For my test cases, this resulted in

  1. rotation-invariant output - rotating input geometry does not change NICS_perp value
  2. agreement with NICS_zz when the ring is already aligned to the $xy$ plane

I've been using this implementation in my own work and haven't run into issues, though I haven't done exhaustive tests.

The postProcessingDriver.py and mathUtilities.py files in my fork of this repo have my implementation of this function, though it does not currently work with the GUI (I've been using pyAroma headless).

The following code, adapted from the implementation in my fork, might work if dropped into pyaroma_main.py:

    def computeNICSPerp(self):
	ringNo_zz = int(ringCombo_2.currentText())
	bqNo_zz = int(bqCombo.currentText())

        ringNormal = np.array(geomAnalyzer.normal_vector(ringList[ringNo_zz], geomList))
        
        rotationMatrix = mathUtilities.align_matrix(ringNormal,np.array([0,0,1]))
    
        if not 1 - np.dot(rotationMatrix @ np.array([0,0,1]), ringNormal) < 0.001:
            raise RuntimeError('Bad change of basis')
        
        i = bqNo_zz
        currentTensor = np.array(
            [[xxTen[i], xyTen[i], xzTen[i]],
             [yxTen[i], yyTen[i], yzTen[i]],
             [zxTen[i], zyTen[i], zzTen[i]]]
        )

        #the change of basis formula for a matrix
        rotatedTensor =  np.linalg.inv(rotationMatrix) @ currentTensor @ rotationMatrix

        #the new NICS_zz with change of basis applied
        new_nics = rotatedTensor[2,2]
    
	nicszzOutText.setText(f'{new_nics:.4f}')

Let me know if you’d like help integrating this or want to discuss further.

Best,
Gage

@wongzit
Copy link
Owner
wongzit commented Apr 28, 2025

Dear Gage,

Thank you so much for your comments and for providing the code.
If possible, I would like to use your code in the next version update. I will mention your credit in the code and on the page.

All the best,
Zhe

@zedo-heptulose
Copy link
Author

Yes, I would absolutely be okay with this. I'll try and conduct some more thorough testing on this code as well.

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
0