Skip to content

Commit 26e750c

Browse files
committed
chore: 1D 시뮬레이션 표시 및 실험 설정 조정
1 parent be7b2a3 commit 26e750c

3 files changed

Lines changed: 17 additions & 8 deletions

File tree

src/component/workspace/AnalysisControl/AnalysisControl.jsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import './AnalysisControl.css';
1010
const EVOLUTION_FRAME_INTERVAL_MS = 33;
1111
const MAX_EVOLUTION_STEPS_PER_FRAME = 8;
1212
const PLAYBACK_SPEEDS = [0.25, 0.5, 1, 2, 4];
13+
const ENERGY_GROUP_TOLERANCE = 0.005;
14+
const ENERGY_LEVEL_TOP_Y = 36;
15+
const ENERGY_LEVEL_BOTTOM_Y = 152;
1316

1417
const clamp = (value, min, max) => Math.min(max, Math.max(min, value));
1518

@@ -40,7 +43,7 @@ const getEnergyGroups = (levels) => {
4043
const groups = [];
4144

4245
levels.forEach((level) => {
43-
const group = groups.find(item => Math.abs(item.energy - level.energy) < 1e-6);
46+
const group = groups.find(item => Math.abs(item.energy - level.energy) <= ENERGY_GROUP_TOLERANCE);
4447

4548
if (group) {
4649
group.levels.push(level);
@@ -142,15 +145,21 @@ function StationaryLevelPicker({
142145
canCalculate,
143146
}) {
144147
const hasLevels = levels.length > 0;
145-
const minEnergy = hasLevels ? Math.min(...levels.map(level => level.energy)) : 0;
146-
const maxEnergy = hasLevels ? Math.max(...levels.map(level => level.energy)) : 1;
147-
const range = Math.max(maxEnergy - minEnergy, 1);
148+
const anchorBottomEnergy = hasLevels ? levels[0].energy : 0;
149+
const anchorTopEnergy = hasLevels
150+
? levels.find(level => level.n === 5)?.energy ?? levels[levels.length - 1].energy
151+
: 1;
152+
const anchorRange = Math.max(anchorTopEnergy - anchorBottomEnergy, 0.001);
148153
const selectedLevel = hasLevels ? levels.find(level => level.n === selectedIndex) ?? levels[0] : null;
149154
const selectedSliderIndex = hasLevels
150155
? Math.max(0, levels.findIndex(level => level.n === selectedLevel.n))
151156
: -1;
152157
const groups = getEnergyGroups(levels);
153-
const toY = (energy) => 152 - ((energy - minEnergy) / range) * 116;
158+
const toY = (energy) => {
159+
const ratio = clamp((energy - anchorBottomEnergy) / anchorRange, 0, 1);
160+
161+
return ENERGY_LEVEL_BOTTOM_Y - ratio * (ENERGY_LEVEL_BOTTOM_Y - ENERGY_LEVEL_TOP_Y);
162+
};
154163

155164
return (
156165
<div className="stationary-editor">

src/component/workspace/PhysicalParameters/PhysicalParameters.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ const LIMITS = {
77
mass: { min: 0.001, max: Number.MAX_SAFE_INTEGER },
88
gridSteps: {
99
min: 16,
10-
max1D: 256,
10+
max1D: 512,
1111
max2D: 512,
1212
},
1313
};
1414

1515
const SLIDER_LIMITS = {
1616
mass: { min: 0.1, max: 20 },
1717
gridSteps: {
18-
max1D: 256,
18+
max1D: 512,
1919
max2D: 256,
2020
},
2121
};

src/context/SimulationContext.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export const SimulationContext = createContext(null);
8686
const initialCommonState = {
8787
type: '1D',
8888
mass: 1.0,
89-
length: 20.0,
89+
length: 40.0,
9090
gridSteps: 64,
9191
timeStep: 0.1,
9292
potentialMode: 'draw',

0 commit comments

Comments
 (0)