bicarlsen / easy-biologic

Python library for communicating with Biologic devices.
GNU General Public License v3.0
18 stars 11 forks source link

rate of JV_Scan #5

Closed chemyibinjiang closed 2 years ago

chemyibinjiang commented 2 years ago

The unit of the rate in args is defined as mV/s [Default: 10]. When call the run function, this following value is past: 'Scan_Rate': [ ch_params[ 'rate' ] 10e-3 ] 5, Since 10e-3 = 0.01 in python, does it scale the scan rate correctly? One of my colleagues found it was not consistent.

bicarlsen commented 2 years ago

Ah, yes, I believe I adjusted for the V -> mV conversion unecessarily, and even messed it up at that. I have fixed the issue in release 0.3.0.post1 and in the latest commit.

Please give the new code a try and let me know if it has resolved the issue.

chemyibinjiang commented 2 years ago

Thanks for the comments. If you want to make the code consistent with the description, I believe it should be 'Scan_Rate': [ ch_params[ 'rate' ] 1e-3 ] 5 so that the unit of it is still mV/s. Also, is there any plan to add a CV Scan function so that it goes from E1 to E2, then goes back to E1 with multiple cycles?

bicarlsen commented 2 years ago

In the ECLab documentation (EC-Lab Development Package manual, sec 7.3.2) it says the scan rate should be given in mV/s, which is also the units used in the easy_biologic documentation, but let me know if I'm mistaken or if you still see a mismatch in rates.

I currently don't have a plan to add a functionality like that. One solution would be to just create a loop running JV_scans. If you would like to add something like that though, please submit it as a Pull Request.

bicarlsen commented 2 years ago

Another option for repeating the scans would be to essentially copy the JV_Scan class and change the N_Cycles parameter (see EC-Lab Development Package User's Guide sec. 7.3.2 for details). I believe that indicates how many times to repeat the technique.

If you want to try that, let me know. I'd be happy to help with any questions, and to also include it in the package.

chemyibinjiang commented 2 years ago

Hello, Sorry for the late reply. We did some tests regarding the JV scan rate based on the current package. We ran the following codes:

Initialization

import easy_biologic # Initialization import sys import logging bl_potentiostat = easy_biologic.BiologicDevice('USB0') bl_potentiostat.connect(bin_file="C:\Users\group\Documents\GitHub\easy-biologic\easy_biologic\techniques-6.01\kernel.bin", xlx_file="C:\Users\group\Documents\GitHub\easy-biologic\easy_biologic\techniques-6.01\Vmp_ii_0437_a6.xlx")

define program

jv = easy_biologic.base_programs.JV_Scan(device = bl_potentiostat,params = {'start': 0.8,"end":-0.2,'step': 0.01, 'rate': 1, 'average': False},channels = [0])

run time

t_start = time.time() jv.run() t_end = time.time() print(t_end-t_start) # 2.539466381072998

If the scan rate is taken with the unit of mV/s, since the scan range is from 0.8 V to -0.2V and we input the rate as 1 mV/s, at least a total time of 2*(0.8+0.2)(V)/1(mV/s) = 2000 s should be required, but it only takes around 2 seconds. So maybe a factor should be given in the run function in JV_Scan? Increasing the cycle number of JV_Scan should work and we will do further tests on it, and share the code later!

Thanks for your comments!

bicarlsen commented 2 years ago

Wonderful, thank you so much for testing that. I will add the correct factor into the code and push a patch.

chemyibinjiang commented 2 years ago

Hello, Sorry for the late reply again. We did further test to make the JV_Scan with multiple cycles. Interestingly, by passing directly N_Cycles to the JV_Scan function, or using a for-loop to run the JV_Scan program, the results are different. These results are shown in the following two figures. image (1) image (2) The first figure corresponds to the one using for-loop, and the second figure corresponds to the one using the N_Cycles within the function. A sharp corner is observed if we used the for-loop. It seems using the N_Cycles directly in the function is more reasonable. There are small peaks during the scan, but we assume it is due to the relatively small working electrode used here. This package is really convenient and thanks for the discussion!

bicarlsen commented 2 years ago

Glad to hear you got it working and find it useful :)

Using a for loop will reset the Biologic on each loop which is liklely the cause of the sharp corner, where as the N_Cycles will not rest the device, but just go inot the next measurement.

I'll close this conversation now, but if anything else comes up, please feel free to raise another Issue.