Skip to content

Commit

Permalink
deploy: ee5988c
Browse files Browse the repository at this point in the history
  • Loading branch information
ndem0 committed Mar 1, 2024
1 parent fa46e75 commit 311b4c8
Show file tree
Hide file tree
Showing 114 changed files with 3,696 additions and 1,545 deletions.
2 changes: 1 addition & 1 deletion .buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: a765572ea3a7b0e12f8c5177dc95c950
config: e773860857a5b1a8ff889f437af7e263
tags: 645f666f9bcd5a90fca523b33c5a78b7
14 changes: 8 additions & 6 deletions _LICENSE.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<html class="writer-html5" lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>License &mdash; PINA 0.1 documentation</title><link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<title>License &mdash; PINA 0.1.0.post2403 documentation</title><link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/copybutton.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="_static/copybutton.css" />


<!--[if lt IE 9]>
<script src="_static/js/html5shiv.min.js"></script>
<![endif]-->
Expand Down Expand Up @@ -37,7 +39,7 @@
<img src="_static/pina_logo.png" class="logo" alt="Logo"/>
</a>
<div class="version">
0.1
0.1.0.post2403
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
Expand Down Expand Up @@ -120,8 +122,8 @@ <h1>License<a class="headerlink" href="#license" title="Permalink to this headli
<hr/>

<div role="contentinfo">
<p>&#169; Copyright Copyright 2021-2023, PINA Contributors.
<span class="lastupdated">Last updated on Nov 17, 2023.
<p>&#169; Copyright Copyright 2021-2024, PINA Contributors.
<span class="lastupdated">Last updated on Mar 01, 2024.
</span></p>
</div>

Expand Down
14 changes: 8 additions & 6 deletions _cite.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<html class="writer-html5" lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Cite PINA &mdash; PINA 0.1 documentation</title><link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<title>Cite PINA &mdash; PINA 0.1.0.post2403 documentation</title><link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/copybutton.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="_static/copybutton.css" />


<!--[if lt IE 9]>
<script src="_static/js/html5shiv.min.js"></script>
<![endif]-->
Expand Down Expand Up @@ -36,7 +38,7 @@
<img src="_static/pina_logo.png" class="logo" alt="Logo"/>
</a>
<div class="version">
0.1
0.1.0.post2403
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
Expand Down Expand Up @@ -116,8 +118,8 @@ <h1>Cite PINA<a class="headerlink" href="#cite-pina" title="Permalink to this he
<hr/>

<div role="contentinfo">
<p>&#169; Copyright Copyright 2021-2023, PINA Contributors.
<span class="lastupdated">Last updated on Nov 17, 2023.
<p>&#169; Copyright Copyright 2021-2024, PINA Contributors.
<span class="lastupdated">Last updated on Mar 01, 2024.
</span></p>
</div>

Expand Down
Binary file added _images/tutorial_19_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _images/tutorial_5_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 9 additions & 6 deletions _modules/index.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<html class="writer-html5" lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Overview: module code &mdash; PINA 0.1 documentation</title><link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<title>Overview: module code &mdash; PINA 0.1.0.post2403 documentation</title><link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/copybutton.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="../_static/copybutton.css" />


<!--[if lt IE 9]>
<script src="../_static/js/html5shiv.min.js"></script>
<![endif]-->
Expand Down Expand Up @@ -35,7 +37,7 @@
<img src="../_static/pina_logo.png" class="logo" alt="Logo"/>
</a>
<div class="version">
0.1
0.1.0.post2403
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
Expand Down Expand Up @@ -105,6 +107,7 @@ <h1>All modules for which code is available</h1>
<li><a href="pina/geometry/union_domain.html">pina.geometry.union_domain</a></li>
<li><a href="pina/label_tensor.html">pina.label_tensor</a></li>
<li><a href="pina/loss.html">pina.loss</a></li>
<li><a href="pina/model/base_no.html">pina.model.base_no</a></li>
<li><a href="pina/model/deeponet.html">pina.model.deeponet</a></li>
<li><a href="pina/model/feed_forward.html">pina.model.feed_forward</a></li>
<li><a href="pina/model/fno.html">pina.model.fno</a></li>
Expand Down Expand Up @@ -134,8 +137,8 @@ <h1>All modules for which code is available</h1>
<hr/>

<div role="contentinfo">
<p>&#169; Copyright Copyright 2021-2023, PINA Contributors.
<span class="lastupdated">Last updated on Nov 17, 2023.
<p>&#169; Copyright Copyright 2021-2024, PINA Contributors.
<span class="lastupdated">Last updated on Mar 01, 2024.
</span></p>
</div>

Expand Down
43 changes: 24 additions & 19 deletions _modules/pina/callbacks/adaptive_refinment_callbacks.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<html class="writer-html5" lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>pina.callbacks.adaptive_refinment_callbacks &mdash; PINA 0.1 documentation</title><link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
<title>pina.callbacks.adaptive_refinment_callbacks &mdash; PINA 0.1.0.post2403 documentation</title><link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../../_static/copybutton.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="../../../_static/copybutton.css" />


<!--[if lt IE 9]>
<script src="../../../_static/js/html5shiv.min.js"></script>
<![endif]-->
Expand Down Expand Up @@ -35,7 +37,7 @@
<img src="../../../_static/pina_logo.png" class="logo" alt="Logo"/>
</a>
<div class="version">
0.1
0.1.0.post2403
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
Expand Down Expand Up @@ -87,7 +89,7 @@
<div itemprop="articleBody">

<h1>Source code for pina.callbacks.adaptive_refinment_callbacks</h1><div class="highlight"><pre>
<span></span><span class="sd">&#39;&#39;&#39;PINA Callbacks Implementations&#39;&#39;&#39;</span>
<span></span><span class="sd">&quot;&quot;&quot;PINA Callbacks Implementations&quot;&quot;&quot;</span>

<span class="c1"># from lightning.pytorch.callbacks import Callback</span>
<span class="kn">from</span> <span class="nn">pytorch_lightning.callbacks</span> <span class="kn">import</span> <span class="n">Callback</span>
Expand All @@ -97,18 +99,17 @@ <h1>Source code for pina.callbacks.adaptive_refinment_callbacks</h1><div class="

<div class="viewcode-block" id="R3Refinement"><a class="viewcode-back" href="../../../_rst/callbacks/adaptive_refinment_callbacks.html#pina.callbacks.adaptive_refinment_callbacks.R3Refinement">[docs]</a><span class="k">class</span> <span class="nc">R3Refinement</span><span class="p">(</span><span class="n">Callback</span><span class="p">):</span>


<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sample_every</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> PINA Implementation of an R3 Refinement Callback.</span>

<span class="sd"> This callback implements the R3 (Retain-Resample-Release) routine for sampling new points based on adaptive search.</span>
<span class="sd"> The algorithm incrementally accumulates collocation points in regions of high PDE residuals, and releases those </span>
<span class="sd"> The algorithm incrementally accumulates collocation points in regions of high PDE residuals, and releases those</span>
<span class="sd"> with low residuals. Points are sampled uniformly in all regions where sampling is needed.</span>

<span class="sd"> .. seealso::</span>

<span class="sd"> Original Reference: Daw, Arka, et al. *Mitigating Propagation Failures in Physics-informed Neural Networks </span>
<span class="sd"> Original Reference: Daw, Arka, et al. *Mitigating Propagation Failures in Physics-informed Neural Networks</span>
<span class="sd"> using Retain-Resample-Release (R3) Sampling. (2023)*.</span>
<span class="sd"> DOI: `10.48550/arXiv.2207.02338</span>
<span class="sd"> &lt;https://doi.org/10.48550/arXiv.2207.02338&gt;`_</span>
Expand Down Expand Up @@ -168,7 +169,7 @@ <h1>Source code for pina.callbacks.adaptive_refinment_callbacks</h1><div class="
<span class="c1"># !!!!!! From now everything is performed on CPU !!!!!!</span>

<span class="c1"># average loss</span>
<span class="n">avg</span> <span class="o">=</span> <span class="p">(</span><span class="n">tot_loss</span><span class="o">.</span><span class="n">mean</span><span class="p">())</span><span class="o">.</span><span class="n">to</span><span class="p">(</span><span class="s1">&#39;cpu&#39;</span><span class="p">)</span>
<span class="n">avg</span> <span class="o">=</span> <span class="p">(</span><span class="n">tot_loss</span><span class="o">.</span><span class="n">mean</span><span class="p">())</span><span class="o">.</span><span class="n">to</span><span class="p">(</span><span class="s2">&quot;cpu&quot;</span><span class="p">)</span>

<span class="c1"># points to keep</span>
<span class="n">old_pts</span> <span class="o">=</span> <span class="p">{}</span>
Expand All @@ -179,25 +180,29 @@ <h1>Source code for pina.callbacks.adaptive_refinment_callbacks</h1><div class="
<span class="n">pts</span> <span class="o">=</span> <span class="n">pts</span><span class="o">.</span><span class="n">cpu</span><span class="p">()</span><span class="o">.</span><span class="n">detach</span><span class="p">()</span>
<span class="n">residuals</span> <span class="o">=</span> <span class="n">res_loss</span><span class="p">[</span><span class="n">location</span><span class="p">]</span><span class="o">.</span><span class="n">cpu</span><span class="p">()</span>
<span class="n">mask</span> <span class="o">=</span> <span class="p">(</span><span class="n">residuals</span> <span class="o">&gt;</span> <span class="n">avg</span><span class="p">)</span><span class="o">.</span><span class="n">flatten</span><span class="p">()</span>
<span class="k">if</span> <span class="nb">any</span><span class="p">(</span><span class="n">mask</span><span class="p">):</span> <span class="c1"># if there are residuals greater than averge we append them</span>
<span class="n">pts</span> <span class="o">=</span> <span class="n">pts</span><span class="p">[</span><span class="n">mask</span><span class="p">]</span> <span class="c1"># TODO masking remove labels</span>
<span class="k">if</span> <span class="nb">any</span><span class="p">(</span>
<span class="n">mask</span>
<span class="p">):</span> <span class="c1"># if there are residuals greater than averge we append them</span>
<span class="n">pts</span> <span class="o">=</span> <span class="n">pts</span><span class="p">[</span><span class="n">mask</span><span class="p">]</span> <span class="c1"># TODO masking remove labels</span>
<span class="n">pts</span><span class="o">.</span><span class="n">labels</span> <span class="o">=</span> <span class="n">labels</span>
<span class="n">old_pts</span><span class="p">[</span><span class="n">location</span><span class="p">]</span> <span class="o">=</span> <span class="n">pts</span>
<span class="n">tot_points</span> <span class="o">+=</span> <span class="nb">len</span><span class="p">(</span><span class="n">pts</span><span class="p">)</span>

<span class="c1"># extract new points to sample uniformally for each location</span>
<span class="n">n_points</span> <span class="o">=</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_tot_pop_numb</span> <span class="o">-</span> <span class="n">tot_points</span><span class="p">)</span> <span class="o">//</span> <span class="nb">len</span><span class="p">(</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_sampling_locations</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_sampling_locations</span>
<span class="p">)</span>
<span class="n">remainder</span> <span class="o">=</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_tot_pop_numb</span> <span class="o">-</span> <span class="n">tot_points</span><span class="p">)</span> <span class="o">%</span> <span class="nb">len</span><span class="p">(</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_sampling_locations</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_sampling_locations</span>
<span class="p">)</span>
<span class="n">n_uniform_points</span> <span class="o">=</span> <span class="p">[</span><span class="n">n_points</span><span class="p">]</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_sampling_locations</span><span class="p">)</span>
<span class="n">n_uniform_points</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">+=</span> <span class="n">remainder</span>

<span class="c1"># sample new points</span>
<span class="k">for</span> <span class="n">numb_pts</span><span class="p">,</span> <span class="n">loc</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">n_uniform_points</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_sampling_locations</span><span class="p">):</span>
<span class="n">trainer</span><span class="o">.</span><span class="n">_model</span><span class="o">.</span><span class="n">problem</span><span class="o">.</span><span class="n">discretise_domain</span><span class="p">(</span><span class="n">numb_pts</span><span class="p">,</span>
<span class="s1">&#39;random&#39;</span><span class="p">,</span>
<span class="n">locations</span><span class="o">=</span><span class="p">[</span><span class="n">loc</span><span class="p">])</span>
<span class="n">trainer</span><span class="o">.</span><span class="n">_model</span><span class="o">.</span><span class="n">problem</span><span class="o">.</span><span class="n">discretise_domain</span><span class="p">(</span>
<span class="n">numb_pts</span><span class="p">,</span> <span class="s2">&quot;random&quot;</span><span class="p">,</span> <span class="n">locations</span><span class="o">=</span><span class="p">[</span><span class="n">loc</span><span class="p">]</span>
<span class="p">)</span>
<span class="c1"># adding previous population points</span>
<span class="n">trainer</span><span class="o">.</span><span class="n">_model</span><span class="o">.</span><span class="n">problem</span><span class="o">.</span><span class="n">add_points</span><span class="p">(</span><span class="n">old_pts</span><span class="p">)</span>

Expand All @@ -222,7 +227,7 @@ <h1>Source code for pina.callbacks.adaptive_refinment_callbacks</h1><div class="
<span class="n">locations</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">condition_name</span> <span class="ow">in</span> <span class="n">problem</span><span class="o">.</span><span class="n">conditions</span><span class="p">:</span>
<span class="n">condition</span> <span class="o">=</span> <span class="n">problem</span><span class="o">.</span><span class="n">conditions</span><span class="p">[</span><span class="n">condition_name</span><span class="p">]</span>
<span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">condition</span><span class="p">,</span> <span class="s1">&#39;location&#39;</span><span class="p">):</span>
<span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">condition</span><span class="p">,</span> <span class="s2">&quot;location&quot;</span><span class="p">):</span>
<span class="n">locations</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">condition_name</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_sampling_locations</span> <span class="o">=</span> <span class="n">locations</span>

Expand Down Expand Up @@ -257,8 +262,8 @@ <h1>Source code for pina.callbacks.adaptive_refinment_callbacks</h1><div class="
<hr/>

<div role="contentinfo">
<p>&#169; Copyright Copyright 2021-2023, PINA Contributors.
<span class="lastupdated">Last updated on Nov 17, 2023.
<p>&#169; Copyright Copyright 2021-2024, PINA Contributors.
<span class="lastupdated">Last updated on Mar 01, 2024.
</span></p>
</div>

Expand Down
Loading

0 comments on commit 311b4c8

Please sign in to comment.