SINGROUP / PyVAFM

Python Virtual Atomic Force Microscope
http://singroup.github.io/PyVAFM
Other
13 stars 1 forks source link

1D MFM Simulation #7

Open WienerSchnitzel123 opened 3 years ago

WienerSchnitzel123 commented 3 years ago

Hi, for my bachelorthesis I am currently working on simulating the interaction between the magnetic field of striplines and the cantilever. Therefore I want to simulate the phase shift of the cantilever. I only have a 1 dimensional forcefield in x- direction and would like to simulate the cantilever moving in x direction over the striplines. I used your NaCl file as template and adjusted the forcefield interpollation and scan area accordingly. But something is not working out. Could you help me find the issue? For pll.df I only get a result looking like an oscillation, which changes with the resolution of the "image". If I use your NaClforces.dat pll.df looks good. I'm currently using this forcefield: Forces_calc3xy1.txt

and this is the code I'm using:

import sys
sys.path.append('/home/ubuntu/Documents/PythonAFM/src') 
#!/usr/bin/env python
from vafmcircuits import Machine
from customs_pll import *

def main():

    machine = Machine(machine=None, name='machine', dt=5.0e-8)

    canti = machine.AddCircuit(type='Cantilever',name='canti', startingz=1,
        Q=10000, k=167.0, f0=15000, pushed=True)

    machine.AddCircuit(type='waver',name='wave',freq=15000,amp=1)

    machine.AddCircuit(type="Machine",name='amp', fcut=10000, assembly=aAMPD, 
        pushed=True)

    machine.AddCircuit(type='PI', name='agc', Kp=1.1, Ki=800, set=1, pushed=True)
    machine.AddCircuit(type="limiter",name='agclim', min=0,max=10, pushed=True)

    machine.AddCircuit(type="Machine",name='pll', fcut=1000, assembly=aPLL, 
        filters=[10000,5000,2000], gain=600.0, f0=15000, Kp=0.5, Ki=700, 
        pushed=True)

    machine.AddCircuit(type='opMul',name='pllinv',in2=-1, pushed=True)
    machine.AddCircuit(type='opMul',name='exc', pushed=True)

    scanner = machine.AddCircuit(type='Scanner',name='scan', Process = machine, pushed=True)

    inter = machine.AddCircuit(type='i3Dlin',name='inter', components=3, pushed=True)
    inter.Configure(steps=[0.1,1,1], npoints=[40,1,1])
    inter.Configure(pbc=[False,True,True])
    inter.Configure(ForceMultiplier=1e10)
    inter.ReadData('Forces_calc3xy1.dat')

    #Outputs
    out1 = machine.AddCircuit(type='output',name='output',file='testafm.out', dump=2)
    out1.Register('global.time', 'canti.zabs','amp.norm','pll.cos','pll.sin','exc.in2')
    out1.Stop()

    out2 = machine.AddCircuit(type='output',name='output2',file='testafm2.out', dump=100)
    out2.Register('global.time', 'canti.ztip','agc.out','pll.df',"canti.fz")

    #Imaging output
    imager = machine.AddCircuit(type='output',name='image',file='NaCl.dat', dump=0)
    imager.Register("scan.x","scan.y","pll.df") 

    #feed x and y to interpolation
    machine.Connect("scan.x" , "inter.x")
    machine.Connect("scan.y" , "inter.y")
    machine.Connect("scan.z" , "canti.holderz")
    machine.Connect("canti.zabs" , "inter.z")

    #Force
    machine.Connect("inter.F3" , "canti.fz")    

    machine.Connect('canti.ztip','amp.signal')
    machine.Connect('amp.amp','agc.signal')
    machine.Connect('amp.norm','pll.signal1')
    machine.Connect('pll.sin','pll.signal2')

    machine.Connect('agc.out','agclim.signal')
    machine.Connect('agclim.out','exc.in1')
    machine.Connect('pll.sin','pllinv.in1')
    machine.Connect('pllinv.out','exc.in2')

    machine.Connect('exc.out','canti.exciter')

    machine.Connect("scan.record","image.record")   

    '''
    machine.Wait(0.01)
    out1.Start()
    machine.Wait(0.001)
    out1.Stop()
    machine.Wait(0.05)
    out1.Start()
    machine.Wait(0.001)
    '''

    scanner.Place(x=-21,y=1,z=1)
    machine.Wait(0.2)   

    scanner.Move(x=1,y=0,z=0)
    machine.Wait(1) 

    scanner.Recorder = imager
    scanner.BlankLines = True 
    #resolution of the image [# points per line, # lines]
    scanner.Resolution = [400,64]
    scanner.ImageArea(40,1)        
    #scan
    scanner.ScanArea()

if __name__ == '__main__':
        main()
DrSpacemanMD commented 3 years ago

Hi

I think I see at least one of the problems, so your force field looks like to me as if its just one line along x. This won't work, the cantilever will oscillate in the z direction so your forcefield needs to have some samples in that direction.

I suspect the sharp discontinuity caused by the line of points is causing the PLL to have a hard time locking.

WienerSchnitzel123 commented 3 years ago

Hi thank you so much for the quick response :) I'm gonna try using a 2D Force field by adding data for the z-axis. This should be sufficient when only scanning one line along the x-Axis right?

WienerSchnitzel123 commented 3 years ago

Hmm now that I've added z=0 and z=2 data to the force field (just copy&paste so it is constant in z direction at the moment) it seems to struggle with interpololating the force field. I get the error "WARNING! i3Dlin 00B!" this is the settings for the interpolation part: inter = machine.AddCircuit(type='i3Dlin',name='inter', components=3, pushed=True) inter.Configure(steps=[0.0001,0.1,1], npoints=[40,1,3]) inter.Configure(pbc=[False,True,False]) inter.Configure(ForceMultiplier=1e10) inter.ReadData('Forces_calcxy3.dat') this is the Force field used: Forces_calcxy3.txt

DrSpacemanMD commented 3 years ago

It seems its only periodic in the y direction so that might be the issue.

WienerSchnitzel123 commented 3 years ago

Thanks, that actually was the issue. When I plot the 1D result still looks like noise though. Especially compared to a plot of the force field. Do you have any idea what could be the reason for that?

DrSpacemanMD commented 3 years ago

The first step is to ensure your cantilever is stable far from the surface (ie when the force is essentially 0) then to slowly bring it closer to the surface.

Be careful of the ForceMultiplier=1e10 this will depend on the units used in the forcefield so yours might not be 1e10.

fullmetalfelix commented 3 years ago

Hi,

as John mentioned already, the cantilever oscillates (usually) in the vertical direction. The frequency shift is dependent on the shape of the force curve that the tip feels during the oscillation. If your force field has the same values at z=0 and z=2, there will be no gradient in forces, so the frequency shift is expected to be zero. As the scanner moves along x, even if the values of force change, they remain constant along z, so perhaps any signal you see might just be amplified noise (hard to tell without seeing the full input and output).

I checked the txt file you attached and I am not sure the file is correct. It has been a while but I remember that the first three numbers in the force file should be indexes (i,j,k) of the grid point, and the rest are force components. Your file has negative indexes, and the j is always 1 (zero is missing?). Anyway, the main issue is the lack of a realistic z-dependence in the force field.