The diesel engine remains one of the key components in the global economy, transporting most of the worlds goods. To cope with stricter regulations and the continuous demand for lower fuel consumption, optimization is a key method. To enable mathematical optimization of the diesel engine, appropriate models need to be developed. These are preferably continuously differentiable, in order to be used with a gradient-based optimization solver. Demonstration of the optimization-based methodology is also necessary in order for the industry to adapt it. The paper presents a complete mean value engine model structure, tailored for optimization and simulation purposes. The model is validated using measurements on a heavyduty diesel engine. The validated model is used to study the transient performance during a time-optimal tip-in, the results validate that the model is suitable for simulation and optimization studies.