Fix some issues related to the Courant number
step_h was using the wrong timestep; fixing it caused update issues based on the Courant number being 1.0, i.e. too large. Reducing it to \sqrt{3}/3 fixes stability issues. Unfortunately, a non-Unity Courant value prevents me from using the ideal Absorbing Boundary Condition I had just implemented, so that's been disabled.
This commit is contained in:
@@ -5,7 +5,7 @@ use crate::mat;
|
||||
use crate::sim::{Cell, GenericSim};
|
||||
use crate::meas::AbstractMeasurement;
|
||||
use font8x8::{BASIC_FONTS, GREEK_FONTS, UnicodeFonts as _};
|
||||
use log::trace;
|
||||
use log::{trace, info};
|
||||
use image::{RgbImage, Rgb};
|
||||
use imageproc::{pixelops, drawing};
|
||||
use std::fs::File;
|
||||
@@ -62,8 +62,14 @@ struct RenderSteps<'a> {
|
||||
|
||||
impl<'a> RenderSteps<'a> {
|
||||
fn render(state: &'a dyn GenericSim, measurements: &'a [Box<dyn AbstractMeasurement>], z: u32) -> RgbImage {
|
||||
let width = 768;
|
||||
let height = width * state.height() / state.width();
|
||||
let mut width = 1920;
|
||||
let mut height = width * state.height() / state.width();
|
||||
if height > 1080 {
|
||||
let stretch = 1080 as f32 / height as f32;
|
||||
width = (width as f32 * stretch) as _;
|
||||
height = 1080;
|
||||
}
|
||||
trace!("rendering at {}x{}", width, height);
|
||||
let mut me = Self::new(state, measurements, width, height, z);
|
||||
me.render_scalar_field(10.0, false, 2, |cell| cell.mat().conductivity().mag());
|
||||
me.render_scalar_field(100.0, true, 0, |cell| cell.mat().m().mag());
|
||||
@@ -161,9 +167,10 @@ impl<'a> RenderSteps<'a> {
|
||||
for x in 0..8 {
|
||||
if (bmp & 1 << x) != 0 {
|
||||
let real_x = 2 + i as u32*8 + x;
|
||||
let real_y = y as u32 + self.im.height() - 10 - meas_no as u32 * 8;
|
||||
if real_x < self.im.width() {
|
||||
self.im.put_pixel(real_x, real_y, Rgb([0, 0, 0]));
|
||||
if let Some(real_y) = (y as u32 + self.im.height()).checked_sub(10 + meas_no as u32 * 8) {
|
||||
if real_x < self.im.width() {
|
||||
self.im.put_pixel(real_x, real_y, Rgb([0, 0, 0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user