UM-PEPL / HallThruster.jl

An open-source fluid Hall thruster code
Other
16 stars 9 forks source link

Curve fitting for adjustment of anomalous parameters #140

Open bboyeleven opened 1 month ago

bboyeleven commented 1 month ago

Hi. 🙌 I am currently trying to write a python code that is using the curve_fit function from the package scipy.optimize to try to fit some external data (electron mobility to be precise) with the physic model from HallThruster.jl.

The goal of doing so is to run the simulation once, recover the classical and electron-wall collision frequency in the python code and adjust the anomalous parameters (that modifies the anomalous collision frequency and so the total collision frequency and so the electron mobility) to match the external data by using the curve_fit function with the anomalous parameters as varying variables.

It works pretty well, except I didn't implement yet this part from the source file update_electrons.jl because I don't understand it yet :

    # Update the anomalous collision frequency multiplier to match target
    # discharge current
    if control_current && t >
        Ki = Kp / Ti

        A1 = Kp + Ki*dt
        A2 = -Kp

        α = 1 - exp(-params.dt[]/smoothing_time_constant[])
        Id_smoothed[] = α * Id[] + (1 - α) * Id_smoothed[]

        errors[3] = errors[2]
        errors[2] = errors[1]
        errors[1] = target_current - Id_smoothed[]

        # PID controller
        if t > Ti
            new_anom_mult = log(anom_multiplier[]) + A1 * errors[1] + A2 * errors[2]
            anom_multiplier[] = exp(new_anom_mult)
        end
    elseif t == 0
        Id_smoothed[] = Id[]
        anom_multiplier[] = 1.0
    end

What is the target discharge current ? And why using a PID control ? This part of the code is used to calculate a variable called anom_multiplier[] which is then used in the calculation of anomalous collision frequency

@inbounds for i in 1:ncells
        # Multiply by anom anom multiplier for PID control
        νan[i] *= anom_multiplier[]

This work could be very interesting to calibrate the anomalous model of HallThruster.jl to external data to perform accurate simulation on different thrusters. And then if you have a 1D code that performs accurately and quick, you can build up a database and trying to identify physic correlations (especially for anomalous model).

archermarx commented 1 month ago

Hi,

The code has a PID controller to scale the anomalous transport up and down to match a target discharge current. It does nothing by default unless a target current is supplied by the user. You shouldn't need to worry about it.