Current Calculation in lammps

Hello, How can i calculate ion flux or movement from defined region in lammps for current calcualtion

You are the only one who knows what the “current calculation” is all about. Without sharing an input deck, there is little to discuss.


How to apply this in the lammps

There is no ready-made “do this, not that” kind of solution.

In my opinion, the most straightforward way to compute this property, would be to write out a custom dump with atom IDs, charge, and (unwrapped?) atom positions, and then write a custom script to compute this property with the specific knowledge of your system geometry. That will also give you the most flexibility with respect to which atoms to include and what time interval to choose in order to have converged and reliable results.

Technically, it should also be possible to use an atom style variable, fix store/state, and compute reduce/region with fix ave/time or fix print to compute the same. But it can be a bit complex if you are not familiar with those LAMMPS features.

I am following your method to find my ion in crystalline structure but i am not able to store cx in fix/ave can you please help me,how can i store this data

variable lx index 10.0
variable ly index 10.0
variable lz index 10.0
variable ex atom q*vx
variable ey atom q*vy
variable ez atom q*vz

compute current all compute reduce sum v_ex v_ey v_ez
variable cx equal c_current[1]/v_lx
variable cy equal c_current[2]/v_ly
variable cz equal c_current[3]/v_lz

cx, cy, cz would then be the current in the corresponding directions (there is no mention of using the total displacement), these can then be fed to a fix ave/time command to get less noisy data averaged over multiple steps.

This is not what I suggested. There are issues in multiple details. As I already noted, doing this kind of analysis requires proper familiarity with LAMMPS input commands, including the ability to learn from the the documentation what is not explicitly stated there in examples.

Sorry, but I don’t have the time to figure this out for you or to debug your attempts at writing a LAMMPS input scripts. My primary recommendation remains to write this analysis as a post-processing tool for a custom trajectory dump file.

Calculating ionic current / flux has been recently discussed here: Compute displace/atom & electric ionic current if you can follow that discussion, you should be able to implement the needed calculations (many issues are touched on in the thread, including comparing velocity and displacement-based approaches).

EDIT: @akohlmey and I just realised that you had simply copied his code and statements from that thread without clearly saying where you had copied it from. This is really surprising and unhelpful behavior for two reasons.

Firstly, the scientific standard requires us to always cite where we have used specific material written by other people. Even though this is an internet forum and not a scientific journal, LAMMPS is a scientific software used primarily by scientists and we would expect all LAMMPS users and forum users to adhere by the same principle.

Secondly, the LAMMPS forum is run by volunteers in our spare time; when we share our expertise (or mistakes!) to help people who have questions we are doing so with very little expectation of reward. It is the very least that users acknowledge when another user has written a script or text so that the author gets credit – our sense of wanting to help people is often the only reward we will have. In addition, it means we can straight away understand the background for your issue and know your competency level instead of making wrong assumptions. After all, I took quite some time to find the old thread and post the link, and that means I have less time now to actually think about what your issue might be and try to help you.

So in future please be very clear whenever you reuse other people’s work. :slight_smile:

2 Likes