diff --git a/src/examples/research/building7m_advanced/acoustics_node.h b/src/examples/research/building7m_advanced/acoustics_node.h index ec4fc9cc..f4baaca4 100644 --- a/src/examples/research/building7m_advanced/acoustics_node.h +++ b/src/examples/research/building7m_advanced/acoustics_node.h @@ -24,6 +24,9 @@ class acoustics_node : public atomic_node // Ports: port, std::pair>> building_layout_input; + port wall_sound_absorption_input; + port floor_sound_absorption_input; + port ceiling_sound_absorption_input; port, quantity>> sound_source_input; port>> sound_field_output; @@ -33,7 +36,11 @@ class acoustics_node : public atomic_node array2d L; // building layout int64 nx; // number of cells in the x dimension int64 ny; // number of cells in the y dimension - float64 wall_R; // wall resistance + distance d; // distance between cells + distance h; // height of ceiling + float64 wall_alpha; // wall sound absorption coefficient + float64 floor_alpha; // floor sound absorption coefficient + float64 ceiling_alpha; // ceiling sound absorption coefficient array2d> SF; // sound field std::map, quantity>> S; // sound sources array2d> TLM; // transmission line matrix grid @@ -51,6 +58,9 @@ class acoustics_node : public atomic_node inline acoustics_node::acoustics_node(const std::string& node_name, const node_context& external_context) : atomic_node(node_name, external_context) , building_layout_input("building_layout_input", external_interface()) + , wall_sound_absorption_input("wall_sound_absorption_input", external_interface()) + , floor_sound_absorption_input("floor_sound_absorption_input", external_interface()) + , ceiling_sound_absorption_input("ceiling_sound_absorption_input", external_interface()) , sound_source_input("sound_source_input", external_interface()) , sound_field_output("sound_field_output", external_interface()) { @@ -68,7 +78,11 @@ inline duration acoustics_node::initialization_event() nx = L.dims()[0]; ny = L.dims()[1]; - wall_R = 5.0; + d = building_layout_input.value().second.first; + h = building_layout_input.value().second.second; + wall_alpha = wall_sound_absorption_input.value(); + floor_alpha = floor_sound_absorption_input.value(); + ceiling_alpha = ceiling_sound_absorption_input.value(); SF = array2d>({nx, ny}, 0_g/_m/_s/_s); S = std::map, quantity>>(); TLM = array2d>({nx, ny}, {0.0, 0.0, 0.0, 0.0}); @@ -108,20 +122,27 @@ inline duration acoustics_node::planned_event(duration elapsed_dt) // Update the TLM pressure values auto next_TLM = array2d>({nx, ny}, {0.0, 0.0, 0.0, 0.0}); + float64 wall_G = 1.0 - wall_alpha; + float64 walkable_G = 1.0 - (floor_alpha + ceiling_alpha)*d/(2.0*h); for (int64 ix = 0; ix < nx; ++ix) { for (int64 iy = 0; iy < ny; ++iy) { array1d pos({2}, {ix, iy}); - const auto& Pxs = TLM(pos); + auto& Pxs = TLM(pos); for (int64 idir = 0; idir < 4; ++idir) { auto dir = directions[idir]; - auto dPx = Pxs[idir]/2.0; auto nbr_pos = pos + dir; if ((nbr_pos(0) >= 0) && (nbr_pos(0) < nx) && (nbr_pos(1) >= 0) && (nbr_pos(1) < ny)) { - auto& nbr_Pxs = next_TLM(nbr_pos); - nbr_Pxs[idir] += dPx; - nbr_Pxs[(idir + 1)%4] += dPx; - nbr_Pxs[(idir + 2)%4] -= dPx; - nbr_Pxs[(idir + 3)%4] += dPx; + if (L(nbr_pos) == wall_code) { + Pxs[idir] = -wall_G*Pxs[idir]; + } + else { + auto& nbr_Pxs = next_TLM(nbr_pos); + auto dPx = walkable_G*Pxs[idir]/2.0; + nbr_Pxs[idir] += dPx; + nbr_Pxs[(idir + 1)%4] += dPx; + nbr_Pxs[(idir + 2)%4] -= dPx; + nbr_Pxs[(idir + 3)%4] += dPx; + } } } } diff --git a/src/examples/research/building7m_advanced/building7m.h b/src/examples/research/building7m_advanced/building7m.h index 19b729d0..b1318842 100644 --- a/src/examples/research/building7m_advanced/building7m.h +++ b/src/examples/research/building7m_advanced/building7m.h @@ -16,7 +16,7 @@ void building7m() { thermodynamic_temperature average_T = thermodynamic_temperature(); try { - simulation sim(10_min, 1, std::cout); + simulation sim(5_min, 1, std::cout); sim.top.frame_duration.set_value(250_ms); sim.process_remaining_events(); } diff --git a/src/examples/research/building7m_advanced/building_closed_system.h b/src/examples/research/building7m_advanced/building_closed_system.h index 78171b4d..8bb505b6 100644 --- a/src/examples/research/building7m_advanced/building_closed_system.h +++ b/src/examples/research/building7m_advanced/building_closed_system.h @@ -45,15 +45,15 @@ class building_closed_system : public composite_node building_closed_system::building_closed_system(const std::string& node_name, const node_context& external_context) : composite_node(node_name, external_context) , frame_duration("frame_duration", internal_context(), 30_s) - , outdoor_mean_temperature("outdoor_mean_temperature", internal_context(), 273150_mK + 20_K) - , outdoor_temperature_period("outdoor_temperature_period", internal_context(), 7_min) - , outdoor_temperature_time_step("outdoor_temperature_time_step", internal_context(), 15_s) + , outdoor_mean_temperature("outdoor_mean_temperature", internal_context(), 273150_mK + 22_K) + , outdoor_temperature_period("outdoor_temperature_period", internal_context(), 3_min) + , outdoor_temperature_time_step("outdoor_temperature_time_step", internal_context(), 5_s) , occupant_time_constant("occupant_time_constant", internal_context(), 5_s) , high_temperature("high_temperature", internal_context(), 273150_mK + 25_K) , initial_temperature("initial_temperature", internal_context(), 273150_mK + 20_K) - , initial_temperature_rate("initial_temperature_rate", internal_context(), 80_mK/_s) + , initial_temperature_rate("initial_temperature_rate", internal_context(), 150_mK/_s) , walking_speed("walking_speed", internal_context(), 1400_mm/_s) - , walking_sound("walking_sound", internal_context(), 2_g/_m/_s/_s) + , walking_sound("walking_sound", internal_context(), 10_g/_m/_s/_s) , occupant_count("occupant_count", internal_context(), 5) , building_info("building_info", internal_context()) , initial_positions("initial_positions", internal_context()) diff --git a/src/examples/research/building7m_advanced/building_dynamics_node.h b/src/examples/research/building7m_advanced/building_dynamics_node.h index 6617014a..cb4bafef 100644 --- a/src/examples/research/building7m_advanced/building_dynamics_node.h +++ b/src/examples/research/building7m_advanced/building_dynamics_node.h @@ -106,9 +106,9 @@ building_dynamics_node::building_dynamics_node(const std::string& node_name, con inward_link(building_layout_input, occupant_planning.building_layout_input); inward_link(building_layout_input, occupant_steering.building_layout_input); inward_link(wall_resistance_input, thermodynamics.wall_resistance_input); - //inward_link(wall_sound_absorption_input, acoustics.wall_sound_absorption_input); - //inward_link(floor_sound_absorption_input, acoustics.floor_sound_absorption_input); - //inward_link(ceiling_sound_absorption_input, acoustics.ceiling_sound_absorption_input); + inward_link(wall_sound_absorption_input, acoustics.wall_sound_absorption_input); + inward_link(floor_sound_absorption_input, acoustics.floor_sound_absorption_input); + inward_link(ceiling_sound_absorption_input, acoustics.ceiling_sound_absorption_input); inward_link(initial_positions_input, occupant_planning.initial_positions_input); inward_link(initial_positions_input, occupant_steering.initial_positions_input); inward_link(walking_speed_input, occupant_steering.walking_speed_input); diff --git a/src/examples/research/building7m_advanced/building_info_node.h b/src/examples/research/building7m_advanced/building_info_node.h index b58fbd4b..559f3696 100644 --- a/src/examples/research/building7m_advanced/building_info_node.h +++ b/src/examples/research/building7m_advanced/building_info_node.h @@ -86,7 +86,7 @@ inline void building_info_node::flow_event() // Placing interior wall cells. int64 ix_wall = 3 + (nx - 6)/3; - for (int64 iy = 3; iy < ny - 6; ++iy) { + for (int64 iy = 3; iy < ny - 8; ++iy) { L(ix_wall, iy) = wall_code; } diff --git a/src/examples/research/building7m_advanced/building_vis_node.h b/src/examples/research/building7m_advanced/building_vis_node.h index a96c7db6..d2e2cc27 100644 --- a/src/examples/research/building7m_advanced/building_vis_node.h +++ b/src/examples/research/building7m_advanced/building_vis_node.h @@ -100,10 +100,10 @@ inline duration building_vis_node::unplanned_event(duration elapsed_dt) inline duration building_vis_node::planned_event(duration elapsed_dt) { // Print grid if the frame rate is finite and the temperature field is not empty. + std::string frame_str(""); if (frame_dt.finite() && !TF.empty()) { ++frame_index; - //print("Frame " + tostring(frame_index)); - std::cout << std::endl; + frame_str += ("Frame " + tostring(frame_index) += "\n"); int64 nx = TF.dims()[0]; int64 ny = TF.dims()[1]; for (int64 iy = ny - 1; iy >= 0; --iy) { @@ -149,11 +149,11 @@ inline duration building_vis_node::planned_event(duration elapsed_dt) } line += "|"; } - std::cout << line << std::endl; + frame_str += (line + "\n"); } - std::cout << std::endl; + frame_str += "\n"; } - std::cout << std::flush; + std::cout << frame_str << std::flush; std::this_thread::sleep_for(std::chrono::milliseconds(50)); planned_dt = frame_dt; return planned_dt;