Electric Motor / DC-Motor Simulation

Hello,
this is my first post in the Unity Forums. At the moment I am working on a project with the goal to simulate a AGV (Automated guided vehicle). For realistic behavior i need a good model of an electric engine (AC or DC motor), were preferably the user can set a target speed and the model calculates the acceleration and time.
Has anyone here had any experience in this field or does anyone have an working asset that i could use as a blueprint?

Thanks for your answers and suggestions

If you want a physically accurate model, you should try to implement brushed dc motor mechanics. A motor should be pretty much a stator and a rotor (output axis) with a hinge joint between them.

The torque should depend on the the voltage, and a few other parameters, such as the torque constant (or back-emt constant) and coil resistance. If you want to use target velocity as input parameter, you should use a controller (think PID or just P) to calculate the voltage based on the error. This is the hard way. The easy way would be to just use the motor subcomponent in the hinge joint. It takes a target angular velocity (I think in degrees/second) and a max force (which is really max torque I believe) and it will just sort it out for you.

This is how I calculated torque

public class motorScriptHinge : MonoBehaviour
{
   

    protected float calc_torque(float v)
    {
        Rigidbody rb = rot_axis.GetComponent<Rigidbody>();
        Vector3 local_vel = rot_axis.transform.InverseTransformDirection(rb.angularVelocity - GetComponent<Rigidbody>().angularVelocity);
        float wr = local_vel.y;
        int_ang += wr * Time.deltaTime;
        avg_w = get_avg_w(wr);


        float w = wr;
        w_m = wr;
        float e = k_i * avg_w;

        float I = (v - e) / r;
        float T = k_i * I;
        avg_t = get_avg_t(T);
        return avg_t;
    }
}