Skip to content

Commit

Permalink
Manually assign results for each simulator
Browse files Browse the repository at this point in the history
  • Loading branch information
hendzeld committed Jun 6, 2023
1 parent 158877f commit d5c3175
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/WrapperApp/components/InputEditor/InputEditorPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import {
SimulationInputFiles,
_defaultFlukaInputFiles,
_defaultShInputFiles,
_defaultTopasInputFiles
_defaultTopasInputFiles,
toSimulationInputFiles
} from '../../../types/ResponseTypes';
import { DragDropFiles } from './DragDropFiles';
import { InputFilesEditor } from './InputFilesEditor';
Expand Down Expand Up @@ -63,7 +64,7 @@ export default function InputEditorPanel({ goToRun }: InputEditorPanelProps) {

handleConvert(editorJSON)
.then(inputFiles => {
setInputFiles({ ...inputFiles });
setInputFiles(toSimulationInputFiles(simulator, inputFiles));
enqueueSnackbar('Input files generated', { variant: 'info' });
})
.catch(e => {
Expand All @@ -73,7 +74,7 @@ export default function InputEditorPanel({ goToRun }: InputEditorPanelProps) {
.finally(() => {
setInProgress(false);
});
}, [editorRef, enqueueSnackbar, handleConvert]);
}, [editorRef, enqueueSnackbar, handleConvert, simulator]);

// eslint-disable-next-line react-hooks/exhaustive-deps
const debouncedOnClickGenerate = useCallback(
Expand Down
30 changes: 30 additions & 0 deletions src/types/ResponseTypes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Estimator } from '../JsRoot/GraphData';
import { EditorJson } from '../ThreeEditor/js/EditorJson';
import { SimulationSourceType } from '../WrapperApp/components/Simulation/RunSimulationForm';
import { SimulatorType } from './RequestTypes';
import {
IntersectionToObject,
TypeIdentifiedByKey,
Expand Down Expand Up @@ -72,6 +73,35 @@ export type SimulationInputFiles =
| TopasInputFilesRecord
| FlukaInputFilesRecord;

export function toSimulationInputFiles(simulator: SimulatorType, inputFiles: ShInputFilesRecord | TopasInputFilesRecord | FlukaInputFilesRecord ): SimulationInputFiles {
switch (simulator) {
case SimulatorType.SHIELDHIT: return toShieldhitInputFiles(inputFiles as unknown as ShInputFilesRecord);
case SimulatorType.TOPAS: return toTopasInputFiles(inputFiles as unknown as TopasInputFilesRecord);
case SimulatorType.FLUKA: return toFlukaInputFiles(inputFiles as unknown as FlukaInputFilesRecord);
}
}

function toShieldhitInputFiles(inputFiles: ShInputFilesRecord): SimulationInputFiles {
return {
"beam.dat": inputFiles["beam.dat"],
"geo.dat": inputFiles["geo.dat"],
"detect.dat": inputFiles["detect.dat"],
"mat.dat": inputFiles["mat.dat"],
}
}

function toTopasInputFiles(inputFiles: TopasInputFilesRecord): SimulationInputFiles {
return {
"topas_config.txt": inputFiles["topas_config.txt"],
}
}

function toFlukaInputFiles(inputFiles: FlukaInputFilesRecord): SimulationInputFiles {
return {
"fl_sim.inp": inputFiles["fl_sim.inp"],
}
}

export type TaskTime = {
hours: string;
minutes: string;
Expand Down

0 comments on commit d5c3175

Please sign in to comment.