Create a complete, highly interactive p5.js simulation demonstrating: magnetic field lines in a bar magnet

CRITICAL REQUIREMENTS:
1. ACCURACY: The simulation must be scientifically/mathematically accurate for magnetic field lines in a bar magnet
2. FUNCTIONAL INTERACTIVITY: All sliders and buttons MUST actually control and modify the simulation behavior in real-time
3. EDUCATIONAL: Users should learn about magnetic field lines in a bar magnet through experimentation and parameter manipulation
4. VISUAL PRECISION: Animations should be smooth, realistic, and visually accurate to real-world physics

MANDATORY INTERACTIVE ELEMENTS THAT MUST WORK:
- At least 4-6 sliders controlling key parameters with realistic ranges - these MUST change simulation behavior
- At least 3-4 buttons for actions (reset, pause/play, presets, etc.) - these MUST perform actual functions
- Real-time parameter display showing current values that update as sliders move
- Visual feedback that responds immediately and visibly to control changes
- Mouse interactions where physically meaningful

CRITICAL: CONTROLS MUST BE FUNCTIONAL, NOT DECORATIVE
- Every slider must control a variable that actively affects the simulation
- Every button must perform a meaningful action that changes the simulation state
- Parameter changes must be immediately visible in the simulation output
- Use the actual slider values in mathematical calculations and physics equations

ANIMATION AND TIMING REQUIREMENTS:
- Use realistic time scaling - avoid animations that are too fast or unrealistic
- Implement proper frame rate control using deltaTime or fixed timesteps
- Use realistic physical constants and scaling factors
- Ensure smooth, stable animations at 60fps
- Avoid conflicting visual elements or overlapping controls
- Make animations visually appealing and scientifically accurate

CONTROL IMPLEMENTATION REQUIREMENTS:
- Sliders: Use createSlider(min, max, default, step) with appropriate ranges that make physical sense
- Buttons: Use createButton('Label') with meaningful functions that actually execute
- Position controls below canvas using .position(x, y) - ensure no overlap
- Show parameter values with text() in the main canvas that update in real-time
- Use function declarations for event handlers: function resetSim() {} 
- ALWAYS use slider.value() in your calculations - never ignore slider inputs

CODE FORMAT REQUIREMENTS:
- Use GLOBAL MODE p5.js (NOT instance mode)
- Define setup() and draw() as regular functions
- All variables should be global (use let/var at top level)
- Use standard p5.js function names: createCanvas, background, fill, etc.
- NO sketch wrapper function - write direct p5.js code

SIMULATION ACCURACY FOR MAGNETIC FIELD LINES IN A BAR MAGNET:
- Use correct physics equations, mathematical relationships, or algorithmic principles
- Realistic parameter ranges and default values that make physical sense
- Smooth, continuous animations with proper time scaling
- Proper scaling and units where applicable
- Include scientific constants or realistic coefficients
- ENSURE every parameter controlled by sliders affects the simulation visibly
- Use appropriate time steps and scaling factors to avoid too-fast animations

VISUAL REQUIREMENTS:
- Clear, educational visualization of the concept
- Multiple visual elements (trails, vectors, measurements, etc.) that don't conflict
- Color coding to distinguish different aspects
- Grid lines, axes, or reference markers where helpful
- Immediate and obvious visual response to parameter changes
- Smooth, realistic motion that matches real-world physics
- Proper visual hierarchy - important elements should stand out

EXAMPLE OF FUNCTIONAL CONTROLS WITH PROPER TIMING:
```javascript
// Global variables that ACTUALLY affect simulation
let gravitySlider, dampingSlider;
let gravity = 0.5;  // This gets updated by slider
let damping = 0.99; // This gets updated by slider
let resetBtn, pauseBtn;
let isPaused = false;
let timeScale = 0.02; // Control animation speed

function setup() {
  createCanvas(400, 400);
  
  // Create sliders that CONTROL the simulation with realistic ranges
  gravitySlider = createSlider(0.1, 2.0, 0.5, 0.1);
  gravitySlider.position(10, height + 10);
  
  dampingSlider = createSlider(0.95, 1.0, 0.99, 0.01);
  dampingSlider.position(150, height + 10);
  
  // Create buttons that DO something - positioned to avoid overlap
  resetBtn = createButton('Reset');
  resetBtn.position(10, height + 40);
  
  pauseBtn = createButton('Pause/Play');
  pauseBtn.position(80, height + 40);
}

function draw() {
  background(220);
  
  // ACTUALLY USE the slider values - this is critical!
  gravity = gravitySlider.value();
  damping = dampingSlider.value();
  
  if (!isPaused) {
    // Use gravity and damping in actual physics calculations with proper time scaling
    velocity += gravity * timeScale;
    velocity *= damping;
    position += velocity;
  }
  
  // Show parameter values that update in real-time
  fill(0);
  text('Gravity: ' + gravity.toFixed(2), 10, 20);
  text('Damping: ' + damping.toFixed(3), 10, 40);
  
  // Draw simulation that responds to parameters with realistic motion
  ellipse(position, height/2, 20, 20);
}

// Functions that actually work
function resetSimulation() {
  position = width/2;
  velocity = 0;
}

function togglePause() {
  isPaused = !isPaused;
}
```

IMPORTANT: 
- Focus on the specific physics, mathematics, or principles of magnetic field lines in a bar magnet
- Make controls that ACTUALLY matter for understanding the concept
- Every slider must control a variable used in the simulation
- Every button must perform a visible action
- Ensure the simulation behaves realistically and responds to all controls
- Use proper time scaling to avoid unrealistically fast animations
- Position controls carefully to avoid visual conflicts
- Make animations smooth and scientifically accurate
- Only output JavaScript code, no explanations
- Use global mode p5.js format (no sketch wrapper)
- Position controls below the 400x400 canvas with proper spacing

Generate an accurate, interactive simulation of: magnetic field lines in a bar magnet with WORKING controls and REALISTIC timing