Skip to content

Commit

Permalink
[skip ci] Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
gbarbalinardo committed Oct 4, 2024
1 parent fe29ff0 commit e8c04b0
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 9 deletions.
65 changes: 62 additions & 3 deletions _modules/kaldo/forceconstants.html
Original file line number Diff line number Diff line change
Expand Up @@ -448,13 +448,15 @@ <h1 id="modules-kaldo-forceconstants--page-root">Source code for kaldo.forcecons
<span class="sd">"""</span>
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="kn">from</span> <span class="nn">sparse</span> <span class="kn">import</span> <span class="n">COO</span>
<span class="kn">import</span> <span class="nn">tensorflow</span> <span class="k">as</span> <span class="nn">tf</span>
<span class="kn">from</span> <span class="nn">kaldo.grid</span> <span class="kn">import</span> <span class="n">wrap_coordinates</span>
<span class="kn">from</span> <span class="nn">kaldo.observables.secondorder</span> <span class="kn">import</span> <span class="n">SecondOrder</span>
<span class="kn">from</span> <span class="nn">kaldo.observables.secondorder</span> <span class="kn">import</span> <span class="n">SecondOrder</span><span class="p">,</span><span class="n">parse_tdep_forceconstant</span>
<span class="kn">from</span> <span class="nn">kaldo.observables.thirdorder</span> <span class="kn">import</span> <span class="n">ThirdOrder</span>
<span class="kn">from</span> <span class="nn">kaldo.helpers.logger</span> <span class="kn">import</span> <span class="n">get_logger</span>
<span class="kn">from</span> <span class="nn">kaldo.observables.harmonic_with_q</span> <span class="kn">import</span> <span class="n">HarmonicWithQ</span>
<span class="kn">import</span> <span class="nn">ase.units</span> <span class="k">as</span> <span class="nn">units</span>
<span class="kn">from</span> <span class="nn">ase.geometry</span> <span class="kn">import</span> <span class="n">find_mic</span>
<span class="kn">from</span> <span class="nn">ase.io</span> <span class="kn">import</span> <span class="n">read</span>
<span class="kn">from</span> <span class="nn">sklearn.metrics</span> <span class="kn">import</span> <span class="n">mean_squared_error</span>
<span class="n">logging</span> <span class="o">=</span> <span class="n">get_logger</span><span class="p">()</span>

<span class="n">MAIN_FOLDER</span> <span class="o">=</span> <span class="s1">'displacement'</span>
Expand Down Expand Up @@ -716,7 +718,64 @@ <h1 id="modules-kaldo-forceconstants--page-root">Source code for kaldo.forcecons
<span class="n">cijkl</span><span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">,</span> <span class="n">k</span><span class="p">,</span> <span class="n">l</span><span class="p">]</span> <span class="o">=</span> <span class="n">b</span><span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="n">k</span><span class="p">,</span> <span class="n">j</span><span class="p">,</span> <span class="n">l</span><span class="p">]</span> <span class="o">+</span> <span class="n">b</span><span class="p">[</span><span class="n">j</span><span class="p">,</span> <span class="n">k</span><span class="p">,</span> <span class="n">i</span><span class="p">,</span> <span class="n">l</span><span class="p">]</span> <span class="o">-</span> <span class="n">b</span><span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">,</span> <span class="n">k</span><span class="p">,</span> <span class="n">l</span><span class="p">]</span> <span class="o">+</span> <span class="n">r</span><span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">,</span> <span class="n">k</span><span class="p">,</span> <span class="n">l</span><span class="p">]</span>

<span class="c1"># Denote parameter for irreducible Cij in the unit of GPa</span>
<span class="k">return</span> <span class="n">evperang3togpa</span> <span class="o">*</span> <span class="n">cijkl</span> <span class="o">/</span> <span class="n">evtotenjovermol</span></div>
<span class="k">return</span> <span class="n">evperang3togpa</span> <span class="o">*</span> <span class="n">cijkl</span> <span class="o">/</span> <span class="n">evtotenjovermol</span>


<span class="nd">@staticmethod</span>
<span class="k">def</span> <span class="nf">_calculate_displacement</span><span class="p">(</span><span class="n">atoms</span><span class="p">,</span> <span class="n">initial_structure</span><span class="p">):</span>
<span class="n">disp</span> <span class="o">=</span> <span class="n">atoms</span><span class="o">.</span><span class="n">positions</span> <span class="o">-</span> <span class="n">initial_structure</span><span class="o">.</span><span class="n">positions</span>
<span class="k">return</span> <span class="n">find_mic</span><span class="p">(</span><span class="n">disp</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">),</span> <span class="n">atoms</span><span class="o">.</span><span class="n">cell</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="n">initial_structure</span><span class="o">.</span><span class="n">positions</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>


<span class="nd">@staticmethod</span>
<span class="k">def</span> <span class="nf">_calculate_harmonic_force</span><span class="p">(</span><span class="n">disp</span><span class="p">,</span> <span class="n">second_order_fc</span><span class="p">):</span>
<span class="n">force_harmonic_vec</span> <span class="o">=</span> <span class="o">-</span><span class="n">np</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="n">second_order_fc</span><span class="p">,</span> <span class="n">disp</span><span class="o">.</span><span class="n">flatten</span><span class="p">())</span>
<span class="k">return</span> <span class="n">force_harmonic_vec</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="n">disp</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>


<span class="nd">@staticmethod</span>
<span class="k">def</span> <span class="nf">_calculate_sigma</span><span class="p">(</span><span class="n">md_forces</span><span class="p">,</span> <span class="n">harmonic_forces</span><span class="p">):</span>
<span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">sqrt</span><span class="p">(</span><span class="n">mean_squared_error</span><span class="p">(</span><span class="n">md_forces</span><span class="p">,</span> <span class="n">harmonic_forces</span><span class="p">))</span> <span class="o">/</span> <span class="n">np</span><span class="o">.</span><span class="n">std</span><span class="p">(</span><span class="n">md_forces</span><span class="p">)</span>


<span class="nd">@staticmethod</span>
<span class="k">def</span> <span class="nf">sigma2_tdep_MD</span><span class="p">(</span><span class="n">fc_file</span><span class="o">=</span><span class="s1">'infile.forceconstant'</span><span class="p">,</span> <span class="n">primitive_file</span><span class="o">=</span><span class="s1">'infile.ucposcar'</span><span class="p">,</span>
<span class="n">supercell_file</span><span class="o">=</span><span class="s1">'infile.ssposcar'</span><span class="p">,</span> <span class="n">md_run</span><span class="o">=</span><span class="s1">'dump.xyz'</span><span class="p">):</span>
<span class="w"> </span><span class="sd">"""</span>
<span class="sd"> Calculate the sigma2 value using TDEP and MD data.</span>

<span class="sd"> Parameters</span>
<span class="sd"> ----------</span>
<span class="sd"> fc_file : str, optional</span>
<span class="sd"> Path to the force constant file. Default is 'infile.forceconstant'.</span>
<span class="sd"> primitive_file : str, optional</span>
<span class="sd"> Path to the primitive cell file. Default is 'infile.ucposcar'.</span>
<span class="sd"> supercell_file : str, optional</span>
<span class="sd"> Path to the supercell file. Default is 'infile.ssposcar'.</span>
<span class="sd"> md_run : str, optional</span>
<span class="sd"> Path to the MD trajectory file. Default is 'dump.xyz'.</span>

<span class="sd"> Returns</span>
<span class="sd"> -------</span>
<span class="sd"> float</span>
<span class="sd"> The average sigma2 value.</span>
<span class="sd"> """</span>
<span class="n">initial_structure</span> <span class="o">=</span> <span class="n">read</span><span class="p">(</span><span class="n">supercell_file</span><span class="p">,</span> <span class="nb">format</span><span class="o">=</span><span class="s2">"vasp"</span><span class="p">)</span>
<span class="n">second_order_fc</span> <span class="o">=</span> <span class="n">parse_tdep_forceconstant</span><span class="p">(</span>
<span class="n">fc_file</span><span class="o">=</span><span class="n">fc_file</span><span class="p">,</span>
<span class="n">primitive</span><span class="o">=</span><span class="n">primitive_file</span><span class="p">,</span>
<span class="n">supercell</span><span class="o">=</span><span class="n">supercell_file</span><span class="p">,</span>
<span class="n">symmetrize</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
<span class="n">two_dim</span><span class="o">=</span><span class="kc">True</span>
<span class="p">)</span>
<span class="n">full_MD_traj</span> <span class="o">=</span> <span class="n">read</span><span class="p">(</span><span class="n">md_run</span><span class="p">,</span> <span class="n">index</span><span class="o">=</span><span class="s2">":"</span><span class="p">)</span>
<span class="n">displacements</span> <span class="o">=</span> <span class="p">[</span><span class="n">ForceConstants</span><span class="o">.</span><span class="n">_calculate_displacement</span><span class="p">(</span><span class="n">atoms</span><span class="p">,</span> <span class="n">initial_structure</span><span class="p">)</span> <span class="k">for</span> <span class="n">atoms</span> <span class="ow">in</span> <span class="n">full_MD_traj</span><span class="p">]</span>
<span class="n">force_harmonic</span> <span class="o">=</span> <span class="p">[</span><span class="n">ForceConstants</span><span class="o">.</span><span class="n">_calculate_harmonic_force</span><span class="p">(</span><span class="n">disp</span><span class="p">,</span> <span class="n">second_order_fc</span><span class="p">)</span> <span class="k">for</span> <span class="n">disp</span> <span class="ow">in</span> <span class="n">displacements</span><span class="p">]</span>
<span class="n">sigma_values</span> <span class="o">=</span> <span class="p">[</span><span class="n">ForceConstants</span><span class="o">.</span><span class="n">_calculate_sigma</span><span class="p">(</span><span class="n">atoms</span><span class="o">.</span><span class="n">get_forces</span><span class="p">(),</span> <span class="n">harm_force</span><span class="p">)</span>
<span class="k">for</span> <span class="n">atoms</span><span class="p">,</span> <span class="n">harm_force</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">full_MD_traj</span><span class="p">,</span> <span class="n">force_harmonic</span><span class="p">)]</span>

<span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="n">sigma_values</span><span class="p">)</span></div>

</pre></div>

</article>
Expand Down
2 changes: 1 addition & 1 deletion docsource/code_architecture.html
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@

<section id="Code-Architecture">
<h1 id="docsource-code-architecture--page-root">Code Architecture<a class="headerlink" href="#docsource-code-architecture--page-root" title="Permalink to this heading"></a></h1>
<p><img alt="f0a07292f70b436496d7b61aa9290e3a" class="no-scaled-link" src="../_images/class_diagram.png" style="width: 650px;"/></p>
<p><img alt="8e3a9ea3ab944a418537542413ff9fc4" class="no-scaled-link" src="../_images/class_diagram.png" style="width: 650px;"/></p>
</section>


Expand Down
2 changes: 1 addition & 1 deletion docsource/credits.html
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@

<section id="Acknowledgements">
<h1 id="docsource-credits--page-root">Acknowledgements<a class="headerlink" href="#docsource-credits--page-root" title="Permalink to this heading"></a></h1>
<p><img alt="44e5d6b9e0bf4d598c15783527dbf8f9" class="no-scaled-link" src="../_images/funding.png" style="width: 650px;"/></p>
<p><img alt="1e9e54027006422681bcec1aedbc9de9" class="no-scaled-link" src="../_images/funding.png" style="width: 650px;"/></p>
<p>We gratefully acknowledge support by the Investment Software Fellowships (grant No. ACI-1547580-479590) of the NSF Molecular Sciences Software Institute (grant No. ACI-1547580) at Virginia Tech.</p>
<p>MolSSI builds open source software and data which serves the computational molecular science community. <a class="reference external" href="https://molssi.org/software-projects/">Explore MolSSI’s software infrastructure projects.</a></p>
</section>
Expand Down
2 changes: 1 addition & 1 deletion docsource/introduction.html
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ <h1 id="Features">Features<a class="headerlink" href="#Features" title="Permalin
<p><strong>Scalable</strong>. In a system of N atoms and N_k k points. kALDo uses (3N)^2 floating point numbers to save the state of the system when using QHGK, (Nk x 3N)^2 for the full solution of the BTE and Nk x 3N^2 when using BTE-RTA.</p>
<p><strong>Performance</strong>. The bottleneck, and slow part of ALD simulations is the calculation of the phonons lifetimes and the scattering matrix. This step requires projecting the interatomic potential on 3N phonons modes and the algorithm scales like (Nk x 3N)^3, because of the 3 projections on phonons modes. In kALDo such algorithm is implemented as 2 Nk x 3N tensor multiplications of size Nk x (3N)^2 for BTE calculations while 3N^2 for QHGK.</p>
<p><strong>Open-Source</strong>. Free for the community to use and contribute with edits and suggestion. It is designed on modern software best practices, and we hope to provide a development platform to implement new theory and methods.</p>
<p><img alt="550c9a0875034109a6a8541013fc68a3" class="no-scaled-link" src="../_images/features.png" style="width: 650px;"/></p>
<p><img alt="462bcfbbcfc8474d936f4f88dfc9204a" class="no-scaled-link" src="../_images/features.png" style="width: 650px;"/></p>
</section>


Expand Down
6 changes: 3 additions & 3 deletions docsource/theory.html
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ <h2 id="Quasi-Harmonic-Green-Kubo">Quasi-Harmonic Green Kubo<a class="headerlink
<section id="Workflow">
<h1 id="Workflow">Workflow<a class="headerlink" href="#Workflow" title="Permalink to this heading"></a></h1>
<p>The workflow for ALD calculations is illustrated below</p>
<p><img alt="e0831aff32b74b80b9bcd0e3cc3ad968" class="no-scaled-link" src="../_images/timeline.png" style="width: 650px;"/></p>
<p><img alt="c3c14c68d4744d518d73ee4a2dc0f35b" class="no-scaled-link" src="../_images/timeline.png" style="width: 650px;"/></p>
<p>Here, we present two example simulations of both a periodic and an amorphous structure.</p>
<section id="Ab-initio-silicon-diamond">
<h2 id="Ab-initio-silicon-diamond"><em>Ab initio</em> silicon diamond<a class="headerlink" href="#Ab-initio-silicon-diamond" title="Permalink to this heading"></a></h2>
Expand Down Expand Up @@ -704,7 +704,7 @@ <h2 id="Ab-initio-silicon-diamond"><em>Ab initio</em> silicon diamond<a class="h
</div>
<p>We performed the simulation using the local density approximation for the exchange and correlation functional and a Bachelet-Hamann-Schluter norm-conserving pseudoptential. Kohn-Sham orbitals are represented on a plane-waves basis set with a cutoff of 20 Ry and (8, 8, 8) k-points mesh. The minimized lattice parameter is 5.398A. The third-order IFC is calculated using finite difference displacement on (5, 5, 5) replicas of the irreducible fcc-unit cell, including up to the 5th nearest neighbor.
We obtained the following thermal properties</p>
<p><img alt="6cd8b344a2cc4401bdd5143e910cb064" class="no-scaled-link" src="../_images/si-diamond-observables.png" style="width: 650px;"/></p>
<p><img alt="55e5bb74730c4603bfe304928674bae0" class="no-scaled-link" src="../_images/si-diamond-observables.png" style="width: 650px;"/></p>
<p>The silicon diamond modes analysis is shown above. Quantum (red) and classical (blue) results are compared. a) Normalized density of states, b) Normalized phase-space per mode <img alt="g" class="math" src="../_images/math/86b44067536d63fd1271ac76c4a35eb79a6aa5dd.png"/>, c) lifetime per mode <img alt="\tau" class="math" src="../_images/math/303b8f73dd9a98bea8df8d22419bc3436abe91a9.png"/>, d) mean free path <img alt="\lambda" class="math" src="../_images/math/b67363a3f3c2ddf224f82975c53b7004abc08d20.png"/>, and e) cumulative conductivity <img alt="\kappa_{cum}" class="math" src="../_images/math/b1c775a79651621157c3335eeba4f6b733d71b1d.png"/>.</p>
</section>
<section id="Amorphous-silicon">
Expand All @@ -726,7 +726,7 @@ <h2 id="Amorphous-silicon">Amorphous silicon<a class="headerlink" href="#Amorpho
</pre></div>
</div>
<p>In a simliar treatment to the silicon crystal, a full battery of modal analysis can be calculated with both quantum and classical statistics on the amorphous systems re- turning the phonon DoS as well as the associated lifetimes, generalized diffusivities, normalized phase space and cumulative conductivity</p>
<p><img alt="dffc88877d86471d9a478c8f80d00238" class="no-scaled-link" src="../_images/amorphous.png" style="width: 650px;"/></p>
<p><img alt="13b7711002bb41b991db44b12a1e8111" class="no-scaled-link" src="../_images/amorphous.png" style="width: 650px;"/></p>
<p>Classical and quantum properties for 4096 atom amorphous silicon system are shown above. a) density of states, b) lifetimes, c) diffusivities, and e) cumulative thermal conductivity. In spite of the increased quantum lifetimes, a decrease of 0.17W/m/K is seen in the quantum conductivity. The difference in conductivity is primarily a result of the overestimation of classical high frequency heat capacities.</p>
</section>
<section id="References">
Expand Down

0 comments on commit e8c04b0

Please sign in to comment.