Task: Fixing XTC/DCD time and step writing (openmm/openmm#4879)

org: openmm
repo: openmm
pr_number: 4879
issue_title: Fixing XTC/DCD time and step writing
issue_body: Fixes https://github.com/openmm/openmm/issues/4873 
resolved_issues: title: Fixing XTC/DCD time and step writing
body: The issue involves incorrect time step and frame indexing when writing simulation trajectories in XTC and DCD file formats. Specifically, the current implementation writes inaccurate values for the current simulation step and frame intervals, leading to inconsistencies in the trajectory metadata. This can result in downstream issues when analyzing or appending to these files, as the metadata does not accurately reflect the simulation state.

Expected behavior: The time step and frame indexing in XTC and DCD trajectory files should correctly reflect the simulation's current step and reporting interval. This ensures that the trajectory metadata is accurate and consistent, enabling proper analysis and seamless appending of additional frames to existing files.

## IMPORTANT INSTRUCTIONS

1. If you edit a python file, you MUST run 'make PythonInstall' inside the build directory
2. If you edit a c++ file, you MUST run 'make -j4 && make install" inside the build directory

Reference solution:
fix_patch: diff --git a/wrappers/python/openmm/app/dcdfile.py b/wrappers/python/openmm/app/dcdfile.py
index 335cdc0b79..af65894f62 100644
--- a/wrappers/python/openmm/app/dcdfile.py
+++ b/wrappers/python/openmm/app/dcdfile.py
@@ -145,8 +145,7 @@ def writeModel(self, positions, unitCellDimensions=None, periodicBoxVectors=None
         file.seek(8, os.SEEK_SET)
         file.write(struct.pack('<i', self._modelCount))
         file.seek(20, os.SEEK_SET)
-        file.write(struct.pack('<i', self._firstStep+self._modelCount*self._interval))
-
+        file.write(struct.pack('<i', self._firstStep+(self._modelCount-1)*self._interval))
         # Write the data.
 
         file.seek(0, os.SEEK_END)
diff --git a/wrappers/python/openmm/app/dcdreporter.py b/wrappers/python/openmm/app/dcdreporter.py
index d09d5c149c..0e97bc9660 100644
--- a/wrappers/python/openmm/app/dcdreporter.py
+++ b/wrappers/python/openmm/app/dcdreporter.py
@@ -110,7 +110,7 @@ def report(self, simulation, state):
                     topology.addAtom(atoms[i].name, atoms[i].element, residue)
             self._dcd = DCDFile(
                 self._out, topology, simulation.integrator.getStepSize(),
-                simulation.currentStep, self._reportInterval, self._append
+                self._reportInterval, self._reportInterval, self._append
             )
         positions = state.getPositions(asNumpy=True)
         if self._atomSubset is not None:
diff --git a/wrappers/python/openmm/app/xtcreporter.py b/wrappers/python/openmm/app/xtcreporter.py
index 0a05e59ad6..bace7d98cb 100644
--- a/wrappers/python/openmm/app/xtcreporter.py
+++ b/wrappers/python/openmm/app/xtcreporter.py
@@ -107,7 +107,7 @@ def report(self, simulation, state):
                 self._fileName,
                 topology,
                 simulation.integrator.getStepSize(),
-                simulation.currentStep,
+                self._reportInterval,
                 self._reportInterval,
                 self._append,
             )