Hi!<div><br></div><div>I've just run into the same issue. Thanks, Geng, for shedding some light and providing the hack to fix it! <div><br></div><div>It's unclear to me how to adapt your fortran code to newer versions of cp2k since, as you say, there have been lots of changes.<br></div><div><br></div><div>Have you, by any chance, subsequently written a similar hack for newer versions of cp2k (e.g. v8.1)?<br></div><div><br></div><div>Best,</div><div>Kane</div><div><br></div><div><br></div></div><div class="gmail_quote"><div dir="auto" class="gmail_attr">On Wednesday, August 19, 2020 at 11:33:38 PM UTC+2 ani...@gmail.com wrote:<br/></div><blockquote class="gmail_quote" style="margin: 0 0 0 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div dir="ltr">Thanks a lot!! </div><div dir="ltr"><br><br>On Tuesday, August 18, 2020 at 9:05:44 AM UTC-7, Sun Geng wrote:<blockquote class="gmail_quote" style="margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div>Hi Aniruddha M Dive,</div><div>Below is the code that I changed a few lines in cp2k_shell.F and ase-cp2k calculator. ( You will see the lines I commented out)<br></div><div>Please note that the code is only tested wit cp2k-v6.1 (I found the most recent cp2k code revised cp2k_shell.F significantly).<br></div><div>The idea is that the python code will write a file "
CP2K_POSITIONS" with coordinates instead of writing them into PIPE, <br></div><div>and cp2k_shell will read the positions from the file instead of the PIPE.<br>Best,</div><div>Geng<br></div><div><br></div><div><br></div><div>        IF (para_env%mepos==para_env%source) THEN<br>           !READ (*,*,iostat=iostat) n_atom2<br>           !IF (iostat/=0) CPABORT('setpos read n_atom')<br>           !IF (n_atom2/=SIZE(pos)) THEN<br>           !   CALL my_assert(.FALSE.,'setpos invalid number of atoms',failure)<br>           !   DO i=1,n_atom<br>           !      READ(*,'(a)',iostat=iostat) cmdStr<br>           !      CALL compress(cmdStr,full=.TRUE.)<br>           !      CALL uppercase(cmdStr)<br>           !      IF (cmdStr=='*END') EXIT<br>           !   END DO<br>           !   GOTO 10<br>           !END IF<br>           !READ (*,*,iostat=iostat) pos<br>           !IF (iostat/=0) CPABORT('setpos read coord')<br>           inquire(unit=201,opened=unitalive)<br>           if (unitalive) CPABORT('UNIT 201 is being used')<br>           inquire(file="CP2K_POSITIONS",exist=filepresence)<br>           if (.not. filepresence) CPABORT('FILE CP2K_POSITIONS NOT EXIST')<br>           open(201,action='READ',file="CP2K_POSITIONS",iostat=iostat,status='OLD',form='FORMATTED',ACCESS='SEQUENTIAL')<br>           if (iostat/=0) CPABORT('read CP2K_POSITIONS')<br>           READ(201,*,iostat=iostat) n_atom2<br>           IF (iostat/=0) CPABORT('setpos read n_atom2')<br>           IF (n_atom2/=SIZE(pos)) THEN<br>              CALL my_assert(.FALSE.,'setpos invalid number of atoms',failure)<br>              DO i=1,n_atom<br>                 READ(201,'(a)',iostat=iostat) cmdStr<br>                 CALL compress(cmdStr,full=.TRUE.)<br>                 CALL uppercase(cmdStr)<br>                 IF (cmdStr=='*END') EXIT<br>              END DO<br>              GOTO 10<br>           END IF<br>           READ (201,*,iostat=iostat) pos<br>           CLOSE(201)<br>           IF (iostat/=0) CPABORT('setpos read coord')<br>           pos(:) = pos(:)/pos_fact<br>           READ(*,'(a)',iostat=iostat) cmdStr<br>           CALL compress(cmdStr,full=.TRUE.)<br>           CALL uppercase(cmdStr)<br>           CALL my_assert(cmdStr=='*END',' missing *END',failure)<br>        END IF<br><br><br>---changes in ase cp2k calcualtor -----<br>        if 'positions' in system_changes:<br>            with open("CP2K_POSITIONS","w") as fp:<br>                fp.write("%d\n" % (3*n_atoms))<br>                for pos in self.atoms.get_positions():<br>                    fp.write('%.18e %.18e %.18e\n' % tuple(pos))<br>            self._shell.send('SET_POS %d' % self._force_env_id)<br>            #self._shell.send('%d' % (3 * n_atoms))<br>            #for pos in self.atoms.get_positions():<br>            #    self._shell.send('%.18e %.18e %.18e' % tuple(pos))<br>            self._shell.send('*END')<br>            max_change = float(self._shell.recv())<br>            assert max_change >= 0 # sanity check<br>            self._shell.expect('* READY')<br>            if os.path.isfile("CP2K_POSITIONS"):<br>                os.remove("CP2K_POSITIONS")<br></div><br><div class="gmail_quote"><div dir="auto">在2020年8月17日星期一 UTC-7 下午4:42:29<<a rel="nofollow">ani...@gmail.com</a>> 写道:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Thanks Geng,<div><br></div><div>I went through your earlier post regarding the same issue. Can you send me the respective cp2k_shell.F file that works for you. I would like to incorporate it and check.</div><div><br></div><div>Also can you send me the python script you used as well.</div><div><br></div><div>Best Regards,</div><div>Aniruddha M Dive</div></div><div dir="ltr"><div><br><br>On Monday, August 17, 2020 at 7:44:08 AM UTC-7, Sun Geng wrote:<blockquote class="gmail_quote" style="margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div>Dear 
Aniruddha,</div><div><br></div><div>Sometimes ago, I have encountered a similar problem,</div><div>I think the reason is that the python code communicates positions/forces with the mpi cp2k_shell.popt. <br></div><div>There is a problem when MPI code read the pipe: the MPI code will only read truncated data  (such as positions) from the pipe, not all of them.</div><div>So CP2K_shell.popt is still waiting for more coordinates and gets stuck.</div><div><br></div><div>Best,</div><div>Geng<br></div><div><br></div><div><br></div><br><div class="gmail_quote"><div dir="auto">在2020年8月13日星期四 UTC-7 下午1:20:17<<a rel="nofollow">ani...@gmail.com</a>> 写道:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Thanks Hasan,<div><br></div><div>I was able to get the Cp2K working. However I face another issue. The simulation runs well for few steps and after that I cannot see my output file being updated. The simulation shows running however I am not able to see any output being updated in the cp2k output file as well as the slurm output file. I have attached my job submission script, python script as well as the out files for reference. Could this be a memory issue? </div><div><br></div><div>Best,</div><div>Aniruddha M Dive</div></div><div dir="ltr"><div><br><br>On Tuesday, August 4, 2020 at 10:12:17 AM UTC-7, Hasan Al-Mahayni wrote:</div></div><div dir="ltr"><div><blockquote class="gmail_quote" style="margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello,<div><br></div><div>I had similar problems starting CP2K with ASE earlier this summer. I will attach an example of geometric optimization for a slab, I hope it helps. You need to copy paste a large portion of your cp2k input file in your python script, because ASE does not provide all the input parameters you will need to perform geo_opt. Please find an example attached below.</div><div><br></div><div>Cheers,</div><div><br></div><div>Hasan.</div></div><br></blockquote></div></div><div dir="ltr"><div><blockquote class="gmail_quote" style="margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><div dir="ltr">On Tue, Aug 4, 2020 at 1:16 AM Maxime Van den Bossche <<a rel="nofollow">maxi...@gmail.com</a>> wrote:<br></div></div></blockquote></div></div><div dir="ltr"><div><blockquote class="gmail_quote" style="margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Dear Aniruddha,</div><div><br></div><div>Since you haven't provided a minimal example, nor the error message you're getting</div><div>from ASE or CP2K, I haven't looked into debugging the (bulky) example you sent.</div><br><div>But I don't think you can do the geometry optimization in this way. ASE uses the cp2k_shell binary,</div><div>which seems to only perform single-point calculations but not e.g. geometry optimizations.</div><div><br></div><div>The idea behind cp2k_shell is that the 'driver' (in this case ASE) is the one moving the atoms</div><div>around, and what CP2K does is e.g. calculating the energy and the gradients for a given geometry.<br></div><div><br></div><div>Here is a minimal example of a geometry optimization, and you can work your way up</div><div>from there:</div><div><br></div><div><div style="background-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;border-width:1px"><code><div><div><span style="color:rgb(0,0,136)">from</span><span style="color:rgb(0,0,0)"> ase</span><span style="color:rgb(102,102,0)">.</span><span style="color:rgb(0,0,0)">build </span><span style="color:rgb(0,0,136)">import</span><span style="color:rgb(0,0,0)"> molecule<br></span><span style="color:rgb(0,0,136)">from</span><span style="color:rgb(0,0,0)"> ase</span><span style="color:rgb(102,102,0)">.</span><span style="color:rgb(0,0,0)">calculators</span><span style="color:rgb(102,102,0)">.</span><span style="color:rgb(0,0,0)">cp2k </span><span style="color:rgb(0,0,136)">import</span><span style="color:rgb(0,0,0)"> CP2K<br></span><span style="color:rgb(0,0,136)">from</span><span style="color:rgb(0,0,0)"> ase</span><span style="color:rgb(102,102,0)">.</span><span style="color:rgb(0,0,0)">optimize </span><span style="color:rgb(0,0,136)">import</span><span style="color:rgb(0,0,0)"> BFGS<br><br>atoms </span><span style="color:rgb(102,102,0)">=</span><span style="color:rgb(0,0,0)"> molecule</span><span style="color:rgb(102,102,0)">(</span><span style="color:rgb(0,136,0)">'H2O'</span><span style="color:rgb(102,102,0)">)</span><span style="color:rgb(0,0,0)"><br>atoms</span><span style="color:rgb(102,102,0)">.</span><span style="color:rgb(0,0,0)">center</span><span style="color:rgb(102,102,0)">(</span><span style="color:rgb(0,0,0)">vacuum</span><span style="color:rgb(102,102,0)">=</span><span style="color:rgb(0,102,102)">2.0</span><span style="color:rgb(102,102,0)">)</span><span style="color:rgb(0,0,0)"><br><br>calc </span><span style="color:rgb(102,102,0)">=</span><span style="color:rgb(0,0,0)"> CP2K</span><span style="color:rgb(102,102,0)">(</span><span style="color:rgb(0,0,0)">command</span><span style="color:rgb(102,102,0)">=</span><span style="color:rgb(0,136,0)">'cp2k_shell.sopt'</span><span style="color:rgb(102,102,0)">)</span><span style="color:rgb(0,0,0)"><br>atoms</span><span style="color:rgb(102,102,0)">.</span><span style="color:rgb(0,0,0)">set_calculator</span><span style="color:rgb(102,102,0)">(</span><span style="color:rgb(0,0,0)">calc</span><span style="color:rgb(102,102,0)">)</span><span style="color:rgb(0,0,0)"><br><br>dyn </span><span style="color:rgb(102,102,0)">=</span><span style="color:rgb(0,0,0)"> BFGS</span><span style="color:rgb(102,102,0)">(</span><span style="color:rgb(0,0,0)">atoms</span><span style="color:rgb(102,102,0)">)</span><span style="color:rgb(0,0,0)"><br>dyn</span><span style="color:rgb(102,102,0)">.</span><span style="color:rgb(0,0,0)">run</span><span style="color:rgb(102,102,0)">(</span><span style="color:rgb(0,0,0)">fmax</span><span style="color:rgb(102,102,0)">=</span><span style="color:rgb(0,102,102)">0.05</span><span style="color:rgb(102,102,0)">)</span><span style="color:rgb(0,0,0)"><br></span></div></div></code></div><br></div><div>Best regards,</div><div>Maxime<br></div></div>

<p></p>

-- <br>
You received this message because you are subscribed to the Google Groups "cp2k" group.<br></blockquote></div></blockquote></div></div><div dir="ltr"><div><blockquote class="gmail_quote" style="margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
To unsubscribe from this group and stop receiving emails from it, send an email to <a rel="nofollow">c...@googlegroups.com</a>.</blockquote></div></blockquote></div></div><div dir="ltr"><div><blockquote class="gmail_quote" style="margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/cp2k/df050a2d-1161-4e2c-98c9-0463adcb4c3do%40googlegroups.com?utm_medium=email&utm_source=footer" rel="nofollow" target="_blank" data-saferedirecturl="https://www.google.com/url?hl=en&q=https://groups.google.com/d/msgid/cp2k/df050a2d-1161-4e2c-98c9-0463adcb4c3do%2540googlegroups.com?utm_medium%3Demail%26utm_source%3Dfooter&source=gmail&ust=1610722205858000&usg=AFQjCNGoK7dbiJ9RNZknxsTelwfBhhiw3A">https://groups.google.com/d/msgid/cp2k/df050a2d-1161-4e2c-98c9-0463adcb4c3do%40googlegroups.com</a>.<br>
</blockquote></div></blockquote></div></div></blockquote></div></blockquote></div></div></blockquote></div></blockquote></div></blockquote></div>