Skip to content

Commit f7704f4

Browse files
committed
Merge branch 'master' of ssh://github.com/zingale/pyro2
2 parents 93a0281 + 9de6e24 commit f7704f4

100 files changed

Lines changed: 5032 additions & 152 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CONTRIBUTING.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Contributing
2+
3+
Contributions are welcomed from anyone, including posting issues or
4+
submitting pull requests to the [pyro github](https://github.com/zingale/pyro).
5+
6+
## Issues
7+
8+
Creating an issue on github is a good way to request new features,
9+
file a bug report, or notify us of any difficulties that arise using
10+
pyro.
11+
12+
To request support using pyro, please create an issue on the pyro
13+
github and the developers will be happy to assist you.
14+
15+
If you are reporting a bug, please indicate any information necessary
16+
to reproduce the bug including your version of python.
17+
18+
## Pull Requests
19+
20+
*Any contributions that have the potential to change answers should be
21+
done via pull requests.* A pull request should be generated from your
22+
fork of pyro and target the `master` branch.
23+
24+
The unit and regression tests will run automatically once the PR is
25+
submitted, and then one of the pyro developers will review the PR and
26+
if needed, suggest modifications prior to merging the PR.
27+
28+
If there are a number of small commits making up the PR, we may wish
29+
to squash commits upon merge to have a clean history. *Please ensure
30+
that your PR title and first post are descriptive, since these will be
31+
used for a squashed commit message.*

DEVELOPMENT

Lines changed: 0 additions & 24 deletions
This file was deleted.

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ finite-volume framework. The code is mainly written in python and is
1111
designed with simplicity in mind. The algorithms are written to
1212
encourage experimentation and allow for self-learning of these code
1313
methods.
14-
14+
1515
The latest version of pyro is always available at:
1616

1717
https://github.com/zingale/pyro2
@@ -154,6 +154,8 @@ pyro provides the following solvers (all in 2-d):
154154
variable-coefficient Poisson equation (which inherits from the
155155
constant-coefficient solver).
156156

157+
- `swe`: a solver for the shallow water equations.
158+
157159

158160
## Working with data
159161

@@ -175,6 +177,12 @@ with their data.
175177

176178
- `analysis/`
177179

180+
* `dam_compare.py`: this takes an output file from the
181+
shallow water dam break problem and plots a slice through the domain
182+
together with the analytic solution (calculated in the script).
183+
184+
usage: `./dam_compare.py file`
185+
178186
* `gauss_diffusion_compare.py`: this is for the diffusion solver's
179187
Gaussian diffusion problem. It takes a sequence of output
180188
files as arguments, computes the angle-average, and the plots

_defaults

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@ ymin = 0.0 ; domain minimum y-coordinate
3131
ymax = 1.0 ; domain maximum y-coordinate
3232

3333
xlboundary = reflect ; minimum x BC ('reflect', 'outflow', or 'periodic')
34-
xrboundary = reflect ; maximum x BC ('reflect', 'outflow', or 'periodic')
34+
xrboundary = reflect ; maximum x BC ('reflect', 'outflow', or 'periodic')
3535
ylboundary = reflect ; minimum y BC ('reflect', 'outflow', or 'periodic')
3636
yrboundary = reflect ; maximum y BC ('reflect', 'outflow', or 'periodic')
3737

3838
nx = 25 ; number of zones in the x-direction
3939
ny = 25 ; number of zones in the y-direction
4040

4141

42-
43-
44-
42+
[particles]
43+
do_particles = 0 ; include particles? (1=yes, 0=no)
44+
n_particles = 100 ; number of particles
45+
particle_generator = random ; how do we generate particles? (random, grid)

advection/_defaults

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ v = 1.0 ; advective velocity in y-direction
99
limiter = 2 ; limiter (0 = none, 1 = 2nd order, 2 = 4th order)
1010

1111

12-
13-
12+
[particles]
13+
do_particles = 0
14+
particle_generator = grid

advection/problems/inputs.smooth

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,6 @@ v = 1.0
3434

3535
limiter = 2
3636

37+
[particles]
38+
do_particles = 1
39+
particle_generator = grid

advection/problems/inputs.tophat

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,3 @@ u = 1.0
3232
v = 1.0
3333

3434
limiter = 2
35-

advection/simulation.py

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import advection.advective_fluxes as flx
66
import mesh.patch as patch
77
from simulation_null import NullSimulation, grid_setup, bc_setup
8+
import particles.particles as particles
9+
import util.plot_tools as plot_tools
810

911

1012
class Simulation(NullSimulation):
@@ -25,6 +27,11 @@ def initialize(self):
2527

2628
self.cc_data = my_data
2729

30+
if self.rp.get_param("particles.do_particles") == 1:
31+
n_particles = self.rp.get_param("particles.n_particles")
32+
particle_generator = self.rp.get_param("particles.particle_generator")
33+
self.particles = particles.Particles(self.cc_data, bc, n_particles, particle_generator)
34+
2835
# now set the initial conditions for the problem
2936
problem = importlib.import_module("advection.problems.{}".format(self.problem_name))
3037
problem.init_data(self.cc_data, self.rp)
@@ -73,6 +80,16 @@ def evolve(self):
7380
dens.v()[:, :] = dens.v() + dtdx*(flux_x.v() - flux_x.ip(1)) + \
7481
dtdy*(flux_y.v() - flux_y.jp(1))
7582

83+
if self.particles is not None:
84+
myg = self.cc_data.grid
85+
u = self.rp.get_param("advection.u")
86+
v = self.rp.get_param("advection.v")
87+
88+
u2d = myg.scratch_array() + u
89+
v2d = myg.scratch_array() + v
90+
91+
self.particles.update_particles(self.dt, u2d, v2d)
92+
7693
# increment the time
7794
self.cc_data.t += self.dt
7895
self.n += 1
@@ -87,16 +104,36 @@ def dovis(self):
87104

88105
myg = self.cc_data.grid
89106

90-
plt.imshow(np.transpose(dens.v()),
107+
_, axes, cbar_title = plot_tools.setup_axes(myg, 1)
108+
109+
# plot density
110+
ax = axes[0]
111+
img = ax.imshow(np.transpose(dens.v()),
91112
interpolation="nearest", origin="lower",
92113
extent=[myg.xmin, myg.xmax, myg.ymin, myg.ymax],
93114
cmap=self.cm)
94115

95-
plt.xlabel("x")
96-
plt.ylabel("y")
116+
ax.set_xlabel("x")
117+
ax.set_ylabel("y")
118+
119+
# needed for PDF rendering
120+
cb = axes.cbar_axes[0].colorbar(img)
121+
cb.solids.set_rasterized(True)
122+
cb.solids.set_edgecolor("face")
123+
97124
plt.title("density")
98125

99-
plt.colorbar()
126+
if self.particles is not None:
127+
particle_positions = self.particles.get_positions()
128+
129+
# dye particles
130+
colors = self.particles.get_init_positions()[:, 0]
131+
132+
# plot particles
133+
ax.scatter(particle_positions[:, 0],
134+
particle_positions[:, 1], c=colors, cmap="Greys")
135+
ax.set_xlim([myg.xmin, myg.xmax])
136+
ax.set_ylim([myg.ymin, myg.ymax])
100137

101138
plt.figtext(0.05, 0.0125, "t = {:10.5f}".format(self.cc_data.t))
102139

advection/tests/test_advection.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def setup_method(self):
1919

2020
self.rp.params["mesh.nx"] = 8
2121
self.rp.params["mesh.ny"] = 8
22+
self.rp.params["particles.do_particles"] = 0
2223

2324
self.sim = sn.Simulation("advection", "test", self.rp)
2425
self.sim.initialize()

advection_fv4/simulation.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import mesh.array_indexer as ai
77
import mesh.fv as fv
88
from simulation_null import grid_setup, bc_setup
9+
import particles.particles as particles
910

1011

1112
class Simulation(advection_rk.Simulation):
@@ -26,6 +27,11 @@ def initialize(self):
2627

2728
self.cc_data = my_data
2829

30+
if self.rp.get_param("particles.do_particles") == 1:
31+
n_particles = self.rp.get_param("particles.n_particles")
32+
particle_generator = self.rp.get_param("particles.particle_generator")
33+
self.particles = particles.Particles(self.cc_data, bc, n_particles, particle_generator)
34+
2935
# now set the initial conditions for the problem
3036
problem = importlib.import_module("advection_fv4.problems.{}".format(self.problem_name))
3137
problem.init_data(self.cc_data, self.rp)

0 commit comments

Comments
 (0)