Skip to content
120 changes: 120 additions & 0 deletions app/models/data/deeponet_default_settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
{
"absorption_coefficients": {
"floor": "0.6, 0.69, 0.71, 0.7, 0.63",
"wall1": "0.6, 0.69, 0.71, 0.7, 0.63",
"ceiling": "0.6, 0.69, 0.71, 0.7, 0.63",
"wall2": "0.6, 0.69, 0.71, 0.7, 0.63",
"wall3": "0.6, 0.69, 0.71, 0.7, 0.63",
"wall4": "0.6, 0.69, 0.71, 0.7, 0.63"
},
"msh_path": "MeasurementRoom.msh",
"geo_path": "MeasurementRoom.geo",
"results": [
{
"percentage": 100,
"sourceX": 2,
"sourceY": 2,
"sourceZ": 1.5,
"resultType": "DON",
"responses": [
{
"x": 1.0,
"y": 1.0,
"z": 1.5,
"receiverResults": [],
"receiverResultsUncorrected": []
},
{
"x": 0.5,
"y": 1.0,
"z": 1.5,
"receiverResults": [],
"receiverResultsUncorrected": []
},
{
"x": 1,
"y": 2,
"z": 0.5,
"receiverResults": [],
"receiverResultsUncorrected": []
},
{
"x": 0.5,
"y": 0.5,
"z": 0.5,
"receiverResults": [],
"receiverResultsUncorrected": []
}
]
}
],
"dg_setup": {
"simulationSettings": {
"dg_freq_upper_limit": 400,
"dg_c0": 343,
"dg_rho0": 1.213,
"dg_ir_length": 0.1,
"dg_poly_order": 4,
"dg_ppw": 2,
"dg_cfl": 1
},
"output_path": "tmp/deeponet/",
"output_filename": "dg_sim_results",
"file_format": "npz"
},
"deeponet_train_setup": {
"id": "cube_dummy_1src_fixed_recvs",

"input_dir": "tmp/deeponet/",
"output_dir": "tmp/deeponet/results/",

"train_data_dir": "train_data",
"val_data_dir": "val_data",

"f0_feat": [500.0, 250.0, 167.0],
"normalize_data": true,

"iterations": 1000,
"use_adaptive_weights": true,
"decay_steps": 2000,
"decay_rate": 0.90,
"learning_rate": 1e-3,
"optimizer": "adam",

"__comment1__": "total batch_size is a multiple of branch and coordinate sizes",
"batch_size_branch": 64,
"batch_size_coord": 1000,

"branch_net": {
"architecture": "mod-mlp",
"activation": "sin",
"num_hidden_layers": 3,
"num_hidden_neurons": 512
},
"trunk_net": {
"architecture": "mod-mlp",
"activation": "sin",
"num_hidden_layers": 3,
"num_hidden_neurons": 512
},
"num_output_neurons": 100
},
"deeponet_inference_setup": {
"write_full_wave_field": false,
"snap_to_grid": true,
"write_ir_plots": true,
"write_ir_animations": false,
"write_ir_wav": true,

"recv_positions": [[1.0, 1.0, 1.1],
[0.5, 1.0, 1.5],
[1.0, 0.9, 0.5],
[0.5, 0.5, 0.5]],


"receiver_position_groups": [
"recv_positions"
]
},
"settingsPreset": "Advanced"
}
8 changes: 8 additions & 0 deletions app/models/data/simulation_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,13 @@
"simulationType": "DG",
"repositoryURL": "https://github.com/Building-acoustics-TU-Eindhoven/edg-acoustics/",
"documentationURL": "https://dg-roomacoustics.readthedocs.io/en/latest/"
},
{
"description": "DeepONet for Acoustic Wave Propagation is a deep neural network that trains on other simulation methods (currently uses the Discontinuous Galerkin (DG)), and allows to create impulse responses at arbitrary receiver locations in the space. The latter is currently not yet supported by CHORAS.",
"label": "DeepONet",
"name": "don_setting.json",
"simulationType": "DON",
"repositoryURL": "https://github.com/dtu-act/deeponet-acoustic-wave-prop/",
"documentationURL": "https://github.com/dtu-act/deeponet-acoustic-wave-prop/"
}
]
2 changes: 1 addition & 1 deletion app/schemas/auralization_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class AuralizationSchema(Schema):
id = fields.Integer()
simulationId = fields.Integer()
audioFileId = fields.Integer()
status = fields.Enum(Status, default=Status.Uncreated)
status = fields.Enum(Status, dump_default=Status.Uncreated)
createdAt = fields.String()
updatedAt = fields.String()

Expand Down
4 changes: 2 additions & 2 deletions app/schemas/file_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@


class FileSchema(Schema):
id = fields.Number()
id = fields.Integer()
fileName = fields.Str()
slot = fields.Str()
size = fields.Number()
size = fields.Integer()


class GetSlotSchema(Schema):
Expand Down
2 changes: 1 addition & 1 deletion app/schemas/geometry_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class GeometrySchema(Schema):


class GeometryStartQuerySchema(Schema):
fileUploadId = fields.Number(required=True)
fileUploadId = fields.Integer(required=True)


class GeometryGetQuerySchema(Schema):
Expand Down
2 changes: 1 addition & 1 deletion app/schemas/material_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class MaterialUpdateSchema(Schema):
absorptionCoefficients = fields.List(fields.Float())

class MaterialSchema(MaterialCreateSchema):
id = fields.Number()
id = fields.Integer()
origin = fields.String()
createdAt = fields.String()
updatedAt = fields.String()
2 changes: 1 addition & 1 deletion app/schemas/mesh_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


class MeshSchema(Schema):
id = fields.Number()
id = fields.Integer()
taskId = fields.Integer()

createdAt = fields.Str()
Expand Down
2 changes: 1 addition & 1 deletion app/schemas/model_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


class ModelSchema(Schema):
id = fields.Number()
id = fields.Integer()
name = fields.Str(required=True)
sourceFileId = fields.Integer()
outputFileId = fields.Integer()
Expand Down
2 changes: 1 addition & 1 deletion app/schemas/project_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class ProjectSchema(Schema):
id = fields.Number()
id = fields.Integer()
name = fields.Str(required=True)
description = fields.Str(required=True)
group = fields.Str(required=True)
Expand Down
1 change: 1 addition & 0 deletions app/services/geometry_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import zipfile
import math

import math
import rhino3dm
from flask_smorest import abort

Expand Down
49 changes: 33 additions & 16 deletions app/services/simulation_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,13 @@ def start_solver_task(simulation_id):
source, simulation.receivers, TaskType.MyNewMethod.value
)
)
if simulation.taskType.value in (TaskType.DON.value):
task_statuses.append(create_source_task(TaskType.DON.value, source["id"]))
results_container.append(
create_result_source_object(
source, simulation.receivers, TaskType.DON.value
)
)

sources_tasks.append(
{
Expand Down Expand Up @@ -322,6 +329,7 @@ def start_solver_task(simulation_id):
def run_solver(simulation_run_id: int, json_path: str):
from simulation_backend.DGinterface import dg_method
from simulation_backend.DEinterface import de_method
from simulation_backend.DeepONetInterface import deeponet_method
from simulation_backend.MyNewMethodInterface import mynewmethod_method

from app.db import db
Expand Down Expand Up @@ -396,6 +404,11 @@ def run_solver(simulation_run_id: int, json_path: str):
dg_method(json_file_path=json_path)
logger.info("DG method")

case TaskType.DON:
# MyNewMethod METHOD
deeponet_method(json_file_path=json_path)
logger.info("DeepONet method")

case TaskType.MyNewMethod:
# MyNewMethod METHOD
mynewmethod_method(json_file_path=json_path)
Expand All @@ -416,12 +429,13 @@ def run_solver(simulation_run_id: int, json_path: str):
logger.info("Saving to xlsx...")

# save the simulation result json to xlsx
if not ExportHelper.parse_json_file_to_xlsx_file(
json_path, json_path.replace(".json", ".xlsx")
):
logger.error("Error saving the result to xlsx")
raise "Error saving the result to xlsx"

try:
ExportHelper.parse_json_file_to_xlsx_file(
json_path, json_path.replace(".json", ".xlsx")
)
except Exception as ex:
logger.error(f"Error saving the result to xlsx: {ex}")

# db - save the xlsx file path
export = Export(
name=Path(json_path).name.replace(".json", ".xlsx"),
Expand All @@ -443,19 +457,22 @@ def run_solver(simulation_run_id: int, json_path: str):
json_path.replace(".json", "_pressure.csv"),
json_path.replace(".json", ".wav"),
)

case TaskType.DON:
imp_tot, fs = auralization_calculation_DG(
None,
json_path.replace(".json", "_pressure.csv"),
json_path.replace(".json", ".wav"),
)
# auralization: save the impulse response to xlsx
if not ExportHelper.write_data_to_xlsx_file(
json_path.replace(".json", ".xlsx"),
CustomExportParametersConfig.impulse_response,
{f"{fs}Hz": imp_tot},
):
logger.error(
"Error saving the impulse response to xlsx"
try:
ExportHelper.write_data_to_xlsx_file(
json_path.replace(".json", ".xlsx"),
CustomExportParametersConfig.impulse_response,
{f"{fs}Hz": imp_tot},
)
raise "Error saving the impulse response to xlsx"


except Exception as ex:
logger.error(f"Error saving the impulse response to xlsx: {ex}")

result_container = {}
if json_path is not None:
Expand Down
1 change: 1 addition & 0 deletions app/types/Task.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ class TaskType(Enum):
Mesh = "Mesh"
DE = "DE"
DG = "DG"
DON = "DON"
MyNewMethod = "MyNewMethod"
BOTH = "BOTH"
5 changes: 5 additions & 0 deletions example_settings/de_setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"options": [
{
"name": "Simulation length",
"description": "Selects what parameter determines the length of the simulation. If EDT is selected, the Impulse response length variable will have no effect, and vice versa.",
"id": "sim_len_type",
"type": "string",
"display": "radio",
Expand All @@ -15,6 +16,7 @@
},
{
"name": "Energy decay threshold",
"description": "The threshold (in dB) until when the DE method simulates. Only used if the Simulation length parameter is set to EDT.",
"id": "edt",
"type": "integer",
"display": "text",
Expand All @@ -26,6 +28,7 @@
},
{
"name": "Impulse response length",
"description": "The length of the impulse response the DE method will simulate. Only used if the Simulation length parameter is set to IR length.",
"id": "de_ir_length",
"type": "float",
"display": "text",
Expand All @@ -37,6 +40,7 @@
},
{
"name": "Speed of sound",
"description": "The speed of sound in the medium (air).",
"id": "de_c0",
"type": "float",
"display": "text",
Expand All @@ -48,6 +52,7 @@
},
{
"name": "Characteristic length (mesh)",
"description": "Distance between nodes that the meshing tool aims for (in meters). Higher values yield shorter simulation times, but might cause errors due to a too coarse mesh.",
"id": "de_lc",
"type": "float",
"display": "text",
Expand Down
Loading
Loading