예제 #1
0
def test_calculate():
    calc = calculate_flux(XYZ)
    assert isinstance(calc, list)
    assert len(calc) == 11
    assert len(calc[0]) == 5

    *orig, dol, perc = calc[0]
    assert orig == ["Cash", 120000, 115000]
    assert dol == 5000
    assert round(perc, 2) == 0.04
예제 #2
0
def test_identify():
    flux = identify_flux(calculate_flux(XYZ))
    assert isinstance(flux, list)
    assert len(flux) == 5
    assert [act for act, *_ in flux] == [
        "Accounts Receivable",
        "Inventory",
        "Notes Receivable",
        "Accrued Payroll",
        "Retained Earnings",
    ]
if save_fig:
    basis.save_plot(save_location, iteration, time, x, state, sol, n_ex, plot_limits)
    iteration += 1

while time < end_time:
    
    # Calculate time step
    dt = CLF*dx/basis.time_step(state)
    
    if time + dt >= end_time:
        dt = end_time - time
    
    print(time)
    
    # Time integration
    flux1 = -dt*flux.calculate_flux(state, flux_p, flux_n, phi, n_ex,fix_cavitation)/dx
    
    temp = state + flux1
    if fix_cavitation:
        temp = basis.fix_cavitation(temp)
    flux2 = -dt*flux.calculate_flux(temp, flux_p, flux_n, phi, n_ex,fix_cavitation)/dx
    
    temp = state + .25*flux1 + .25*flux2
    if fix_cavitation:
        temp = basis.fix_cavitation(temp)
    flux3 = -dt*flux.calculate_flux(temp, flux_p, flux_n, phi, n_ex,fix_cavitation)/dx
        
    state = state + (flux1 + flux2 + 4*flux3)/6
    
    if fix_cavitation:
        state = basis.fix_cavitation(state)