Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Alec Hammond committed Mar 7, 2024
1 parent f8497cb commit 9003479
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion python/adjoint/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,9 @@ def smoothed_projection(
)

# Only apply smoothing to interfaces
x_projected_smoothed = (1 - fill_factor_eff) * x_minus_eff + (fill_factor_eff) * x_plus_eff
x_projected_smoothed = (1 - fill_factor_eff) * x_minus_eff + (
fill_factor_eff
) * x_plus_eff

return npa.where(
needs_smoothing,
Expand Down
8 changes: 5 additions & 3 deletions python/examples/waveguide_crossing.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def _plot_optimization_results(
plt.ylabel("FOM")
for k in range(len(samples)):
plt.subplot(2, 4, 5 + k)
plt.imshow(data[samples[k]], cmap="binary")
plt.imshow(data[samples[k]], cmap="binary", vmin=0.0, vmax=1.0)
plt.axis("off")
plt.title(f"It. {samples[k]+1}")
plt.tight_layout()
Expand Down Expand Up @@ -410,7 +410,7 @@ def run_topology_optimization(
solver.set_maxeval(maxeval)

# initial guess, which is just a uniform gray region
x0 = np.ones((Nx, Ny))
x0 = 0.5 * np.ones((Nx, Ny))
x0 = mapping(x0)

# Create empty datastructures we can use to log the results
Expand Down Expand Up @@ -444,6 +444,8 @@ def run_topology_optimization(
f0, _ = opt(need_gradient=False)
results.append(np.real(f0))

_plot_optimization_results(data, results)

# Save to disk
if mp.am_really_master() and (output_filename_prefix is not None):
np.savez(output_filename_prefix + "_data.npz", data=data, results=results)
Expand Down Expand Up @@ -599,7 +601,7 @@ def analyze_FOM_convergence(
run_shape_optimization(resolution=25.0, beta=np.inf, maxeval=30)

run_topology_optimization(
resolution=10.0, beta_evolution=[8, 32, np.inf], maxeval=10
resolution=25.0, beta_evolution=[8, 32, np.inf], maxeval=10
)

analyze_FOM_convergence(resolution=25, beta=64, maxeval=25)
Expand Down

0 comments on commit 9003479

Please sign in to comment.