History_output file

More
1 week 2 days ago #35 by asmamarzouk
History_output file was created by asmamarzouk
Hello, 
I need to use zacros to investigate the diffusion behavior of a particle on a surface. I am using an hexagonal grid 20x20 with lattice = 0.5 (800 point) , that I need to save all the occured events. the  simulation is generating a huge history_output file. Is there a way to save on the history_output file only the occupied points of each configuration, instead of saving for each configuration, all the grid points, even not occupied.?

I would really appreciate your support.
Best

Please Log in or Create an account to join the conversation.

More
1 week 2 days ago - 1 week 2 days ago #36 by Admin
Replied by Admin on topic History_output file
Hi, thanks for reaching out! Such a functionality is not provided in Zacros (not yet anyway). However, you could easily implement a "quick & dirty"/"hacky" solution that would work for your purposes: if you are using Zacros 3.03, go to file output_handle_module.F90 and locate the following line of code in subroutine write_info_to_file:
Code:
      integer site, entity, halo, sumtemp(nsurfspecs)

You will first have to add a definition of an array with the site numbers you want, e.g., make the following amendments to the above part of the code:
Code:
      integer site, entity, halo, sumtemp(nsurfspecs)       integer, allocatable :: sites_req(:)       allocate(sites_req(5)) ! we want to save the state of only 5 sites       sites_req = (/1,2,5,6,7/) ! here we define the site numbers

Then, go a bit further down and locate the following lines:
Code:
case (1) ! lattice snapshots/history          ! *** Write sample to history file          write(ihistory,'(a,I20,1x,I20,1x,ES30.16,1x,ES30.16,1x,ES30.16)') 'configuration ', inumoutput, stepreport, timereport, mech_parser%tempfun(temp,tramp,timereport,1), globalenergy          do i = 1,nsites

The last line above will have to be changed, as shown below:
Code:
case (1) ! lattice snapshots/history          ! *** Write sample to history file          write(ihistory,'(a,I20,1x,I20,1x,ES30.16,1x,ES30.16,1x,ES30.16)') 'configuration ', inumoutput, stepreport, timereport, mech_parser%tempfun(temp,tramp,timereport,1), globalenergy          do k = 1,size(sites_req)             i = sites_req(k)

This way you will only be saving the state of sites 1, 2, 5, 6, and 7, in the history output file, as per the definition of sites_req above.

Similar things apply to Zacros 2.01, but the line after which you should add the definition of sites_req is as follows (still in subroutine write_info_to_file of file output_handle_module.F90):
Code:
    real(8) activenrg, preexpfac0, preexpfac, procpropenstcurtemp  

and then you have:
Code:
        ! *** Write sample to history file         write(ihistory,'(a,I20,1x,I20,1x,ES30.16,1x,ES30.16,1x,ES30.16)') 'configuration ', inumoutput, stepreport, timereport, tempfun(temp,tramp,timereport,1), globalenergy         do i = 1,nsites

which has to be modified as discussed above.

Don't forget to recompile after you make these changes. In fact, it might be a good idea to compile this modified/"hacked" version in a separate directory to avoid confusion in future simulations in which you might need all sites to be reported. Also, please note that if you are using Zacros-post, it will not be able to process the output generated by this modified version of Zacros, so you would have to write custom-postprocessing scripts.
Last edit: 1 week 2 days ago by Admin.

Please Log in or Create an account to join the conversation.

More
1 week 2 days ago #37 by asmamarzouk
Replied by asmamarzouk on topic History_output file
Hi,
Thank you for the prompt and detailed answer.
However, the sites that can be occupied during the KMC steps are unpredictable, thus I am not able to define them in advance. The particle is moving on a random way.
It might be worthy to know that for each configuration I always have only one occupied site.

Thank you again for your support.

Please Log in or Create an account to join the conversation.

More
6 days 8 hours ago #38 by Admin
Replied by Admin on topic History_output file
OK, I see. This seems like a simpler problem to resolve: you want to write only the occupied site, so you can just have a test right after the loop that checks if the site is occupied, and if it's not, cycle to the next iteration of the loop immediately (without writing anything). This can be implemented as follows:
Code:
         ! *** Write sample to history file          write(ihistory,'(a,I20,1x,I20,1x,ES30.16,1x,ES30.16,1x,ES30.16)') 'configuration ', inumoutput, stepreport, timereport, mech_parser%tempfun(temp,tramp,timereport,1), globalenergy          do i = 1,nsites             if (latticestate(i,2) == 0) cycle

In the above, the last line does the cycling mentioned. This is a bit inefficient as an approach, since you are going over all sites, but it is quite general, since it will report all occupied sites if later you want to have more than one particle hopping on the lattice; moreover, you can change the condition as you like in the future.

A more efficient way of doing this would to use the FINDLOC function, to get immediately the position of the non-zero element in the 2nd column of latticestate, and write only the information for that site with one command (no looping over the sites). In particular:
Code:
         ! do i = 1,nsites ! COMMENTED OUT             i = findloc(latticestate(:,2), value = 1, dim = 1) ! Returns only the first site occupied by type-1 adsorbate species
and a few lines later in the code comment out the enddo:
Code:
         ! enddo ! COMMENTED OUT          write(ihistory,'('//int2str(ngasspecs)//'(I20,1x))') (gasspecsnums(j), j = 1,ngasspecs)          flush(ihistory)

Try either of the above and let us know if you need more help.

Please Log in or Create an account to join the conversation.

Time to create page: 0.213 seconds

Sorry, this website uses features that your browser doesn’t support. Upgrade to a newer version of Firefox, Chrome, Safari, or Edge and you’ll be all set.