Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ params.radiation_model = "plane_wave" // plane_wave, flanged_piston, unflanged_
params.num_bands = 8 // Number of parallel jobs for the solver
params.outdir = "./results"

// Directivity (opt-in, single mode only, requires BEM)
params.directivity = false

// Auto mode settings
params.target_f_low = 500
params.target_f_high = 4000
Expand Down Expand Up @@ -177,6 +180,92 @@ process generate_dashboard {
"""
}

process render_horn_3d {
publishDir "${params.outdir}", mode: 'copy'

input:
val throat_radius
val mouth_radius
val length
val profile

output:
path "horn_3d.png"

script:
"""
python3 -m horn_analysis.horn_render \
horn_3d.png \
--throat-radius ${throat_radius} \
--mouth-radius ${mouth_radius} \
--length ${length} \
--profile ${profile}
"""
}

process render_auto_horn_3d {
publishDir "${params.outdir}/auto", mode: 'copy'

input:
val profile

output:
path "horn_3d_${profile}.png"

script:
"""
python3 -m horn_analysis.horn_render \
horn_3d_${profile}.png \
--throat-radius ${params.throat_radius} \
--mouth-radius ${params.mouth_radius} \
--length ${params.length} \
--profile ${profile}
"""
}

process run_simulation_directivity {
publishDir "${params.outdir}", mode: 'copy'

input:
path horn_step

output:
path "directivity.csv"

script:
"""
python3 -m horn_solver.solver \
--step-file ${horn_step} \
--output-file solver_directivity.csv \
--min-freq ${params.min_freq} \
--max-freq ${params.max_freq} \
--num-intervals ${params.num_intervals} \
--length ${params.length} \
--mesh-size ${params.mesh_size} \
--radiation-model bem \
--compute-directivity \
--directivity-file directivity.csv
"""
}

process generate_directivity_plots {
publishDir "${params.outdir}/directivity", mode: 'copy'

input:
path directivity_csv

output:
path "polar_directivity.png"
path "directivity_contour.png"
path "beamwidth.png"
path "directivity_index.png"

script:
"""
python3 -m horn_analysis.directivity_plot ${directivity_csv} --output-dir .
"""
}

// ========================================================================
// Auto mode processes
// ========================================================================
Expand Down Expand Up @@ -414,6 +503,20 @@ workflow single {

// 9. Combined dashboard
generate_dashboard(ch_merged_results)

// 10. 3D horn geometry render (runs in parallel with simulation)
render_horn_3d(
params.throat_radius,
params.mouth_radius,
params.length,
params.profile
)

// 11. Directivity (opt-in, requires BEM)
if (params.directivity) {
ch_directivity_csv = run_simulation_directivity(ch_step_file)
generate_directivity_plots(ch_directivity_csv)
}
}

workflow auto {
Expand Down Expand Up @@ -468,6 +571,10 @@ workflow auto {
ch_drivers_db,
ch_prescreen,
)

// 9. 3D horn geometry renders (one per profile, parallel)
ch_render_profiles = Channel.from("conical", "exponential", "hyperbolic")
render_auto_horn_3d(ch_render_profiles)
}

workflow {
Expand Down
2 changes: 2 additions & 0 deletions packages/horn-analysis/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ horn-prescreen = "horn_analysis.prescreen:main"
horn-rank = "horn_analysis.rank_pipeline:main"
horn-auto-report = "horn_analysis.auto_report:main"
horn-dashboard = "horn_analysis.dashboard:main"
horn-render = "horn_analysis.horn_render:main"
horn-directivity-plot = "horn_analysis.directivity_plot:main"

[project.optional-dependencies]
test = [
Expand Down
Loading