text:
# This file is auto-generated by AWSMetadata.jl
using AWS
using AWS.AWSServices: honeycode
using AWS.Compat
using AWS.UUIDs

"""
    BatchCreateTableRows()

 The BatchCreateTableRows API allows you to create one or more rows at the end of a table in a workbook. The API allows you to specify the values to set in some or all of the columns in the new rows.   If a column is not explicitly set in a specific row, then the column level formula specified in the table will be applied to the new row. If there is no column level formula but the last row of the table has a formula, then that formula will be copied down to the new row. If there is no column level formula and no formula in the last row of the table, then that column will be left blank for the new rows.

# Required Parameters
- `rowsToCreate`:  The list of rows to create at the end of the table. Each item in this list needs to have a batch item id to uniquely identify the element in the request and the cells to create for that row. You need to specify at least one item in this list.   Note that if one of the column ids in any of the rows in the request does not exist in the table, then the request fails and no updates are made to the table.
- `tableId`: The ID of the table where the new rows are being added.  If a table with the specified ID could not be found, this API throws ResourceNotFoundException.
- `workbookId`: The ID of the workbook where the new rows are being added.  If a workbook with the specified ID could not be found, this API throws ResourceNotFoundException.

# Optional Parameters
- `clientRequestToken`:  The request token for performing the batch create operation. Request tokens help to identify duplicate requests. If a call times out or fails due to a transient error like a failed network connection, you can retry the call with the same request token. The service ensures that if the first call using that request token is successfully performed, the second call will not perform the operation again.   Note that request tokens are valid only for a few minutes. You cannot use request tokens to dedupe requests spanning hours or days.
"""
batch_create_table_rows(rowsToCreate, tableId, workbookId; aws_config::AWSConfig=global_aws_config()) = honeycode("POST", "/workbooks/$(workbookId)/tables/$(tableId)/rows/batchcreate", Dict{String, Any}("rowsToCreate"=>rowsToCreate); aws_config=aws_config)
batch_create_table_rows(rowsToCreate, tableId, workbookId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = honeycode("POST", "/workbooks/$(workbookId)/tables/$(tableId)/rows/batchcreate", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("rowsToCreate"=>rowsToCreate), args)); aws_config=aws_config)

"""
    BatchDeleteTableRows()

 The BatchDeleteTableRows API allows you to delete one or more rows from a table in a workbook. You need to specify the ids of the rows that you want to delete from the table.

# Required Parameters
- `rowIds`:  The list of row ids to delete from the table. You need to specify at least one row id in this list.   Note that if one of the row ids provided in the request does not exist in the table, then the request fails and no rows are deleted from the table.
- `tableId`: The ID of the table where the rows are being deleted.  If a table with the specified id could not be found, this API throws ResourceNotFoundException.
- `workbookId`: The ID of the workbook where the rows are being deleted.  If a workbook with the specified id could not be found, this API throws ResourceNotFoundException.

# Optional Parameters
- `clientRequestToken`:  The request token for performing the delete action. Request tokens help to identify duplicate requests. If a call times out or fails due to a transient error like a failed network connection, you can retry the call with the same request token. The service ensures that if the first call using that request token is successfully performed, the second call will not perform the action again.   Note that request tokens are valid only for a few minutes. You cannot use request tokens to dedupe requests spanning hours or days.
"""
batch_delete_table_rows(rowIds, tableId, workbookId; aws_config::AWSConfig=global_aws_config()) = honeycode("POST", "/workbooks/$(workbookId)/tables/$(tableId)/rows/batchdelete", Dict{String, Any}("rowIds"=>rowIds); aws_config=aws_config)
batch_delete_table_rows(rowIds, tableId, workbookId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = honeycode("POST", "/workbooks/$(workbookId)/tables/$(tableId)/rows/batchdelete", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("rowIds"=>rowIds), args)); aws_config=aws_config)

"""
    BatchUpdateTableRows()

 The BatchUpdateTableRows API allows you to update one or more rows in a table in a workbook.   You can specify the values to set in some or all of the columns in the table for the specified rows. If a column is not explicitly specified in a particular row, then that column will not be updated for that row. To clear out the data in a specific cell, you need to set the value as an empty string (\"\").

# Required Parameters
- `rowsToUpdate`:  The list of rows to update in the table. Each item in this list needs to contain the row id to update along with the map of column id to cell values for each column in that row that needs to be updated. You need to specify at least one row in this list, and for each row, you need to specify at least one column to update.   Note that if one of the row or column ids in the request does not exist in the table, then the request fails and no updates are made to the table.
- `tableId`: The ID of the table where the rows are being updated.  If a table with the specified id could not be found, this API throws ResourceNotFoundException.
- `workbookId`: The ID of the workbook where the rows are being updated.  If a workbook with the specified id could not be found, this API throws ResourceNotFoundException.

# Optional Parameters
- `clientRequestToken`:  The request token for performing the update action. Request tokens help to identify duplicate requests. If a call times out or fails due to a transient error like a failed network connection, you can retry the call with the same request token. The service ensures that if the first call using that request token is successfully performed, the second call will not perform the action again.   Note that request tokens are valid only for a few minutes. You cannot use request tokens to dedupe requests spanning hours or days.
"""
batch_update_table_rows(rowsToUpdate, tableId, workbookId; aws_config::AWSConfig=global_aws_config()) = honeycode("POST", "/workbooks/$(workbookId)/tables/$(tableId)/rows/batchupdate", Dict{String, Any}("rowsToUpdate"=>rowsToUpdate); aws_config=aws_config)
batch_update_table_rows(rowsToUpdate, tableId, workbookId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = honeycode("POST", "/workbooks/$(workbookId)/tables/$(tableId)/rows/batchupdate", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("rowsToUpdate"=>rowsToUpdate), args)); aws_config=aws_config)

"""
    BatchUpsertTableRows()

 The BatchUpsertTableRows API allows you to upsert one or more rows in a table. The upsert operation takes a filter expression as input and evaluates it to find matching rows on the destination table. If matching rows are found, it will update the cells in the matching rows to new values specified in the request. If no matching rows are found, a new row is added at the end of the table and the cells in that row are set to the new values specified in the request.   You can specify the values to set in some or all of the columns in the table for the matching or newly appended rows. If a column is not explicitly specified for a particular row, then that column will not be updated for that row. To clear out the data in a specific cell, you need to set the value as an empty string (\"\").

# Required Parameters
- `rowsToUpsert`:  The list of rows to upsert in the table. Each item in this list needs to have a batch item id to uniquely identify the element in the request, a filter expression to find the rows to update for that element and the cell values to set for each column in the upserted rows. You need to specify at least one item in this list.   Note that if one of the filter formulas in the request fails to evaluate because of an error or one of the column ids in any of the rows does not exist in the table, then the request fails and no updates are made to the table.
- `tableId`: The ID of the table where the rows are being upserted.  If a table with the specified id could not be found, this API throws ResourceNotFoundException.
- `workbookId`: The ID of the workbook where the rows are being upserted.  If a workbook with the specified id could not be found, this API throws ResourceNotFoundException.

# Optional Parameters
- `clientRequestToken`:  The request token for performing the update action. Request tokens help to identify duplicate requests. If a call times out or fails due to a transient error like a failed network connection, you can retry the call with the same request token. The service ensures that if the first call using that request token is successfully performed, the second call will not perform the action again.   Note that request tokens are valid only for a few minutes. You cannot use request tokens to dedupe requests spanning hours or days.
"""
batch_upsert_table_rows(rowsToUpsert, tableId, workbookId; aws_config::AWSConfig=global_aws_config()) = honeycode("POST", "/workbooks/$(workbookId)/tables/$(tableId)/rows/batchupsert", Dict{String, Any}("rowsToUpsert"=>rowsToUpsert); aws_config=aws_config)
batch_upsert_table_rows(rowsToUpsert, tableId, workbookId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = honeycode("POST", "/workbooks/$(workbookId)/tables/$(tableId)/rows/batchupsert", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("rowsToUpsert"=>rowsToUpsert), args)); aws_config=aws_config)

"""
    DescribeTableDataImportJob()

 The DescribeTableDataImportJob API allows you to retrieve the status and details of a table data import job.

# Required Parameters
- `jobId`: The ID of the job that was returned by the StartTableDataImportJob request.  If a job with the specified id could not be found, this API throws ResourceNotFoundException.
- `tableId`: The ID of the table into which data was imported.  If a table with the specified id could not be found, this API throws ResourceNotFoundException.
- `workbookId`: The ID of the workbook into which data was imported.  If a workbook with the specified id could not be found, this API throws ResourceNotFoundException.

"""
describe_table_data_import_job(jobId, tableId, workbookId; aws_config::AWSConfig=global_aws_config()) = honeycode("GET", "/workbooks/$(workbookId)/tables/$(tableId)/import/$(jobId)"; aws_config=aws_config)
describe_table_data_import_job(jobId, tableId, workbookId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = honeycode("GET", "/workbooks/$(workbookId)/tables/$(tableId)/import/$(jobId)", args; aws_config=aws_config)

"""
    GetScreenData()

 The GetScreenData API allows retrieval of data from a screen in a Honeycode app. The API allows setting local variables in the screen to filter, sort or otherwise affect what will be displayed on the screen.

# Required Parameters
- `appId`: The ID of the app that contains the screem.
- `screenId`: The ID of the screen.
- `workbookId`: The ID of the workbook that contains the screen.

# Optional Parameters
- `maxResults`:  The number of results to be returned on a single page. Specify a number between 1 and 100. The maximum value is 100.   This parameter is optional. If you don't specify this parameter, the default page size is 100.
- `nextToken`:  This parameter is optional. If a nextToken is not specified, the API returns the first page of data.   Pagination tokens expire after 1 hour. If you use a token that was returned more than an hour back, the API will throw ValidationException.
- `variables`:  Variables are optional and are needed only if the screen requires them to render correctly. Variables are specified as a map where the key is the name of the variable as defined on the screen. The value is an object which currently has only one property, rawValue, which holds the value of the variable to be passed to the screen.
"""
get_screen_data(appId, screenId, workbookId; aws_config::AWSConfig=global_aws_config()) = honeycode("POST", "/screendata", Dict{String, Any}("appId"=>appId, "screenId"=>screenId, "workbookId"=>workbookId); aws_config=aws_config)
get_screen_data(appId, screenId, workbookId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = honeycode("POST", "/screendata", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("appId"=>appId, "screenId"=>screenId, "workbookId"=>workbookId), args)); aws_config=aws_config)

"""
    InvokeScreenAutomation()

 The InvokeScreenAutomation API allows invoking an action defined in a screen in a Honeycode app. The API allows setting local variables, which can then be used in the automation being invoked. This allows automating the Honeycode app interactions to write, update or delete data in the workbook.

# Required Parameters
- `appId`: The ID of the app that contains the screen automation.
- `automationId`: The ID of the automation action to be performed.
- `screenId`: The ID of the screen that contains the screen automation.
- `workbookId`: The ID of the workbook that contains the screen automation.

# Optional Parameters
- `clientRequestToken`:  The request token for performing the automation action. Request tokens help to identify duplicate requests. If a call times out or fails due to a transient error like a failed network connection, you can retry the call with the same request token. The service ensures that if the first call using that request token is successfully performed, the second call will return the response of the previous call rather than performing the action again.   Note that request tokens are valid only for a few minutes. You cannot use request tokens to dedupe requests spanning hours or days.
- `rowId`:  The row ID for the automation if the automation is defined inside a block with source or list.
- `variables`:  Variables are specified as a map where the key is the name of the variable as defined on the screen. The value is an object which currently has only one property, rawValue, which holds the value of the variable to be passed to the screen. Any variables defined in a screen are required to be passed in the call.
"""
invoke_screen_automation(appId, automationId, screenId, workbookId; aws_config::AWSConfig=global_aws_config()) = honeycode("POST", "/workbooks/$(workbookId)/apps/$(appId)/screens/$(screenId)/automations/$(automationId)"; aws_config=aws_config)
invoke_screen_automation(appId, automationId, screenId, workbookId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = honeycode("POST", "/workbooks/$(workbookId)/apps/$(appId)/screens/$(screenId)/automations/$(automationId)", args; aws_config=aws_config)

"""
    ListTableColumns()

 The ListTableColumns API allows you to retrieve a list of all the columns in a table in a workbook.

# Required Parameters
- `tableId`: The ID of the table whose columns are being retrieved.  If a table with the specified id could not be found, this API throws ResourceNotFoundException.
- `workbookId`: The ID of the workbook that contains the table whose columns are being retrieved.  If a workbook with the specified id could not be found, this API throws ResourceNotFoundException.

# Optional Parameters
- `nextToken`:  This parameter is optional. If a nextToken is not specified, the API returns the first page of data.   Pagination tokens expire after 1 hour. If you use a token that was returned more than an hour back, the API will throw ValidationException.
"""
list_table_columns(tableId, workbookId; aws_config::AWSConfig=global_aws_config()) = honeycode("GET", "/workbooks/$(workbookId)/tables/$(tableId)/columns"; aws_config=aws_config)
list_table_columns(tableId, workbookId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = honeycode("GET", "/workbooks/$(workbookId)/tables/$(tableId)/columns", args; aws_config=aws_config)

"""
    ListTableRows()

 The ListTableRows API allows you to retrieve a list of all the rows in a table in a workbook.

# Required Parameters
- `tableId`: The ID of the table whose rows are being retrieved.  If a table with the specified id could not be found, this API throws ResourceNotFoundException.
- `workbookId`: The ID of the workbook that contains the table whose rows are being retrieved.  If a workbook with the specified id could not be found, this API throws ResourceNotFoundException.

# Optional Parameters
- `maxResults`: The maximum number of rows to return in each page of the results.
- `nextToken`:  This parameter is optional. If a nextToken is not specified, the API returns the first page of data.   Pagination tokens expire after 1 hour. If you use a token that was returned more than an hour back, the API will throw ValidationException.
- `rowIds`:  This parameter is optional. If one or more row ids are specified in this list, then only the specified row ids are returned in the result. If no row ids are specified here, then all the rows in the table are returned.
"""
list_table_rows(tableId, workbookId; aws_config::AWSConfig=global_aws_config()) = honeycode("POST", "/workbooks/$(workbookId)/tables/$(tableId)/rows/list"; aws_config=aws_config)
list_table_rows(tableId, workbookId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = honeycode("POST", "/workbooks/$(workbookId)/tables/$(tableId)/rows/list", args; aws_config=aws_config)

"""
    ListTables()

 The ListTables API allows you to retrieve a list of all the tables in a workbook.

# Required Parameters
- `workbookId`: The ID of the workbook whose tables are being retrieved.  If a workbook with the specified id could not be found, this API throws ResourceNotFoundException.

# Optional Parameters
- `maxResults`: The maximum number of tables to return in each page of the results.
- `nextToken`:  This parameter is optional. If a nextToken is not specified, the API returns the first page of data.   Pagination tokens expire after 1 hour. If you use a token that was returned more than an hour back, the API will throw ValidationException.
"""
list_tables(workbookId; aws_config::AWSConfig=global_aws_config()) = honeycode("GET", "/workbooks/$(workbookId)/tables"; aws_config=aws_config)
list_tables(workbookId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = honeycode("GET", "/workbooks/$(workbookId)/tables", args; aws_config=aws_config)

"""
    QueryTableRows()

 The QueryTableRows API allows you to use a filter formula to query for specific rows in a table.

# Required Parameters
- `filterFormula`: An object that represents a filter formula along with the id of the context row under which the filter function needs to evaluate.
- `tableId`: The ID of the table whose rows are being queried.  If a table with the specified id could not be found, this API throws ResourceNotFoundException.
- `workbookId`: The ID of the workbook whose table rows are being queried.  If a workbook with the specified id could not be found, this API throws ResourceNotFoundException.

# Optional Parameters
- `maxResults`: The maximum number of rows to return in each page of the results.
- `nextToken`:  This parameter is optional. If a nextToken is not specified, the API returns the first page of data.   Pagination tokens expire after 1 hour. If you use a token that was returned more than an hour back, the API will throw ValidationException.
"""
query_table_rows(filterFormula, tableId, workbookId; aws_config::AWSConfig=global_aws_config()) = honeycode("POST", "/workbooks/$(workbookId)/tables/$(tableId)/rows/query", Dict{String, Any}("filterFormula"=>filterFormula); aws_config=aws_config)
query_table_rows(filterFormula, tableId, workbookId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = honeycode("POST", "/workbooks/$(workbookId)/tables/$(tableId)/rows/query", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("filterFormula"=>filterFormula), args)); aws_config=aws_config)

"""
    StartTableDataImportJob()

 The StartTableDataImportJob API allows you to start an import job on a table. This API will only return the id of the job that was started. To find out the status of the import request, you need to call the DescribeTableDataImportJob API.

# Required Parameters
- `clientRequestToken`:  The request token for performing the update action. Request tokens help to identify duplicate requests. If a call times out or fails due to a transient error like a failed network connection, you can retry the call with the same request token. The service ensures that if the first call using that request token is successfully performed, the second call will not perform the action again.   Note that request tokens are valid only for a few minutes. You cannot use request tokens to dedupe requests spanning hours or days.
- `dataFormat`:  The format of the data that is being imported. Currently the only option supported is \"DELIMITED_TEXT\".
- `dataSource`:  The source of the data that is being imported. The size of source must be no larger than 100 MB. Source must have no more than 100,000 cells and no more than 1,000 rows.
- `importOptions`:  The options for customizing this import request.
- `tableId`: The ID of the table where the rows are being imported.  If a table with the specified id could not be found, this API throws ResourceNotFoundException.
- `workbookId`: The ID of the workbook where the rows are being imported.  If a workbook with the specified id could not be found, this API throws ResourceNotFoundException.

"""
start_table_data_import_job(clientRequestToken, dataFormat, dataSource, importOptions, tableId, workbookId; aws_config::AWSConfig=global_aws_config()) = honeycode("POST", "/workbooks/$(workbookId)/tables/$(tableId)/import", Dict{String, Any}("clientRequestToken"=>clientRequestToken, "dataFormat"=>dataFormat, "dataSource"=>dataSource, "importOptions"=>importOptions); aws_config=aws_config)
start_table_data_import_job(clientRequestToken, dataFormat, dataSource, importOptions, tableId, workbookId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = honeycode("POST", "/workbooks/$(workbookId)/tables/$(tableId)/import", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("clientRequestToken"=>clientRequestToken, "dataFormat"=>dataFormat, "dataSource"=>dataSource, "importOptions"=>importOptions), args)); aws_config=aws_config)


text:
using SIIPExamples
using PowerSystems
const PSY = PowerSystems

file_dir = joinpath(
    dirname(dirname(pathof(SIIPExamples))),
    "script",
    "4_PowerSimulationsDynamics_examples",
    "Data",
)
omib_sys = System(joinpath(file_dir, "OMIB.raw"))

slack_bus = [b for b in get_components(Bus, omib_sys) if b.bustype == BusTypes.REF][1]
inf_source = Source(
    name = "InfBus", #name
    available = true, #availability
    active_power = 0.0,
    reactive_power = 0.0,
    bus = slack_bus, #bus
    R_th = 0.0, #Rth
    X_th = 5e-6, #Xth
)
add_component!(omib_sys, inf_source)

get_components(Source, omib_sys)

get_components(Generator, omib_sys)

machine_classic() = BaseMachine(
    0.0, #R
    0.2995, #Xd_p
    0.7087, #eq_p
)

shaft_damping() = SingleMass(
    3.148, #H
    2.0, #D
)

avr_none() = AVRFixed(0.0)

tg_none() = TGFixed(1.0) #efficiency

pss_none() = PSSFixed(0.0)

static_gen = get_component(Generator, omib_sys, "generator-102-1")

dyn_gen = DynamicGenerator(
    name = get_name(static_gen),
    ω_ref = 1.0,
    machine = machine_classic(),
    shaft = shaft_damping(),
    avr = avr_none(),
    prime_mover = tg_none(),
    pss = pss_none(),
)

add_component!(omib_sys, dyn_gen, static_gen)

to_json(omib_sys, joinpath(file_dir, "omib_sys.json"), force = true)

sys_file_dir = joinpath(file_dir, "ThreeBusInverter.raw")
threebus_sys = System(sys_file_dir)
slack_bus = [b for b in get_components(Bus, threebus_sys) if b.bustype == BusTypes.REF][1]
inf_source = Source(
    name = "InfBus", #name
    available = true, #availability
    active_power = 0.0,
    reactive_power = 0.0,
    bus = slack_bus, #bus
    R_th = 0.0, #Rth
    X_th = 5e-6, #Xth
)
add_component!(threebus_sys, inf_source)

#Define converter as an AverageConverter
converter_high_power() = AverageConverter(rated_voltage = 138.0, rated_current = 100.0)

#Define Outer Control as a composition of Virtual Inertia + Reactive Power Droop
outer_control() = OuterControl(
    VirtualInertia(Ta = 2.0, kd = 400.0, kω = 20.0),
    ReactivePowerDroop(kq = 0.2, ωf = 1000.0),
)

#Define an Inner Control as a Voltage+Current Controler with Virtual Impedance:
inner_control() = CurrentControl(
    kpv = 0.59,     #Voltage controller proportional gain
    kiv = 736.0,    #Voltage controller integral gain
    kffv = 0.0,     #Binary variable enabling the voltage feed-forward in output of current controllers
    rv = 0.0,       #Virtual resistance in pu
    lv = 0.2,       #Virtual inductance in pu
    kpc = 1.27,     #Current controller proportional gain
    kic = 14.3,     #Current controller integral gain
    kffi = 0.0,     #Binary variable enabling the current feed-forward in output of current controllers
    ωad = 50.0,     #Active damping low pass filter cut-off frequency
    kad = 0.2,      #Active damping gain
)

#Define DC Source as a FixedSource:
dc_source_lv() = FixedDCSource(voltage = 600.0)

#Define a Frequency Estimator as a PLL based on Vikram Kaura and Vladimir Blaskoc 1997 paper:
pll() = KauraPLL(
    ω_lp = 500.0, #Cut-off frequency for LowPass filter of PLL filter.
    kp_pll = 0.084,  #PLL proportional gain
    ki_pll = 4.69,   #PLL integral gain
)

#Define an LCL filter:
filt() = LCLFilter(lf = 0.08, rf = 0.003, cf = 0.074, lg = 0.2, rg = 0.01)

machine_oneDoneQ() = OneDOneQMachine(
    0.0, #R
    1.3125, #Xd
    1.2578, #Xq
    0.1813, #Xd_p
    0.25, #Xq_p
    5.89, #Td0_p
    0.6, #Tq0_p
)

shaft_no_damping() = SingleMass(
    3.01, #H (M = 6.02 -> H = M/2)
    0.0, #D
)

avr_type1() = AVRTypeI(
    20.0, #Ka - Gain
    0.01, #Ke
    0.063, #Kf
    0.2, #Ta
    0.314, #Te
    0.35, #Tf
    0.001, #Tr
    (min = -5.0, max = 5.0),
    0.0039, #Ae - 1st ceiling coefficient
    1.555, #Be - 2nd ceiling coefficient
)

#No TG
tg_none() = TGFixed(1.0) #efficiency

#No PSS
pss_none() = PSSFixed(0.0) #Vs

for g in get_components(Generator, threebus_sys)
    #Find the generator at bus 102
    if get_number(get_bus(g)) == 102
        #Create the dynamic generator
        case_gen = DynamicGenerator(
            get_name(g),
            1.0, # ω_ref,
            machine_oneDoneQ(), #machine
            shaft_no_damping(), #shaft
            avr_type1(), #avr
            tg_none(), #tg
            pss_none(), #pss
        )
        #Attach the dynamic generator to the system by specifying the dynamic and static part
        add_component!(threebus_sys, case_gen, g)
        #Find the generator at bus 103
    elseif get_number(get_bus(g)) == 103
        #Create the dynamic inverter
        case_inv = DynamicInverter(
            get_name(g),
            1.0, # ω_ref,
            converter_high_power(), #converter
            outer_control(), #outer control
            inner_control(), #inner control voltage source
            dc_source_lv(), #dc source
            pll(), #pll
            filt(), #filter
        )
        #Attach the dynamic inverter to the system
        add_component!(threebus_sys, case_inv, g)
    end
end

to_json(threebus_sys, joinpath(file_dir, "threebus_sys.json"), force = true)

# This file was generated using Literate.jl, https://github.com/fredrikekre/Literate.jl

ext: jl


text:
import Pkg
Pkg.instantiate() # downloads all dependencies for the current project
Pkg.add("JSON")

using JSON

dict = Dict()
open("contacts.json", "r") do f
    global dict
    dicttxt = read(f, String)  # file information to string
    dict=JSON.parse(dicttxt)  # parse and transform data
end

first_names = String[]

for contact in dict["emergencyContacts"]
    push!(first_names, split(contact["name"]," ")[1])
end

first_names


text:
using Rubin
using Tests
using Elliptic
using HypergeometricFunctions
using Polylogarithms
using SpecialFunctions

@test integrate((a+b*x+b*f*e^-1*x^2)^2*(d+e*x+f*x^2)^-1//2, x) == :(1//128*e^-2*f^-5//2*((b^2*(3*e^4+48*d^2*f^2+8*d*f*e^2)+128*a^2*e^2*f^2+-32*a*b*e*f*(e^2+4*d*f))*log(e+2*f*x+2*f^(1/2)*(d+x*(e+f*x))^(1/2))+2*b*f^(1/2)*(d+x*(e+f*x))^(1/2)*(e+2*f*x)*(b*(-3*e^2+4*f*(-3d+2*f*x^2)+8*e*f*x)+32*a*e*f)))
@test integrate((d+e*x+f*x^2)^-1//2*(a+b*x+b*f*e^-1*x^2), x) == :(1//4*b*f^-1*(d+e*x+f*x^2)^(1/2)+1//8*f^-3//2*(-1*b*(e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(1/2)*(d+b*x+c*x^2)^-1*(b+2*c*x)*(3*b^2+12*c*(a+-2d)))
@test integrate((a+b*x+c*x^2)^-1//2*(d+b*x+c*x^2)^-4, x) == :(-1*(b^2+-4*c*d)^-1*(-3d+3a)^-1*(a+b*x+c*x^2)^(1/2)*(d+b*x+c*x^2)^-3*(b+2*c*x)+1//8*(a+-1d)^-7//2*(b^2+-4*c*d)^-7//2*(b^2+4*c*(a+-2d))*(5*b^4+16*c^2*(5*a^2+8*d^2+-8*a*d)+-8*c*b^2*(a+4d))*arctanh((a+-1d)^(1/2)*(b^2+-4*c*d)^-1//2*(a+b*x+c*x^2)^-1//2*(b+2*c*x))+-1//24*(a+-1d)^-3*(b^2+-4*c*d)^-3*(a+b*x+c*x^2)^(1/2)*(d+b*x+c*x^2)^-1*(b+2*c*x)*(15*b^4+16*c^2*(15*a^2+44*d^2+-44*a*d)+8*c*b^2*(-22d+7a))+1//12*(a+-1d)^-2*(b^2+-4*c*d)^-2*(a+b*x+c*x^2)^(1/2)*(d+b*x+c*x^2)^-2*(b+2*c*x)*(5*b^2+20*c*(a+-2d)))
@test integrate((d+e*x+f*x^2)^-1//2*(a*e+b*e*x+b*f*x^2)^-2, x) == :(-1*e^-3//2*(b*d+-1*a*e)^-3//2*(b*e+-4*a*f)^-3//2*(-1*b*(e^2+4*d*f)+8*a*e*f)*arctanh(e^-1//2*(b*d+-1*a*e)^(1/2)*(b*e+-4*a*f)^-1//2*(d+e*x+f*x^2)^-1//2*(e+2*f*x))+-1*b*e^-1*(b*d+-1*a*e)^-1*(b*e+-4*a*f)^-1*(d+e*x+f*x^2)^(1/2)*(a*e+b*e*x+b*f*x^2)^-1*(e+2*f*x))
@test integrate((4+x^2+2x)^-1*(5+x^2+2x)^-1//2, x) == :(1//3*3^(1/2)*arctan(1//3*3^(1/2)*(5+x^2+2x)^-1//2*(1+x)))
@test integrate((1+x^2)^-1//2*(1+x^2+2x)^(1/2), x) == :((1+x)^-1*(1+x^2)^(1/2)*(1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x^2+-4x)^-1//2*(3+x))))
@test integrate((2+3x+5*x^2)^4*(3+-1x+2*x^2), x) == :(48x+136*x^2+656*x^4+1176*x^7+475//2*x^10+1064//3*x^3+1250//11*x^11+2377//2*x^6+3415//4*x^8+5075//9*x^9+5099//5*x^5)
@test integrate((2+3x+5*x^2)^3*(3+-1x+2*x^2), x) == :(24x+50*x^2+134*x^6+250//9*x^9+322//3*x^3+325//8*x^8+579//4*x^4+720//7*x^7+876//5*x^5)
@test integrate((2+3x+5*x^2)^2*(3+-1x+2*x^2), x) == :(12x+16*x^2+35//6*x^6+50//7*x^7+83//3*x^3+85//4*x^4+103//5*x^5)
@test integrate((2+3x+5*x^2)*(3+-1x+2*x^2), x) == :(2*x^5+6x+1//4*x^4+7//2*x^2+16//3*x^3)
@test integrate((2+3x+5*x^2)^-1*(3+-1x+2*x^2), x) == :(-11//50*log(2+3x+5*x^2)+2//5*x+143//775*31^(1/2)*arctan(1//31*31^(1/2)*(3+10x)))
@test integrate((2+3x+5*x^2)^-2*(3+-1x+2*x^2), x) == :((310+465x+775*x^2)^-1*(77+143x)+82//961*31^(1/2)*arctan(1//31*31^(1/2)*(3+10x)))
@test integrate((2+3x+5*x^2)^-3*(3+-1x+2*x^2), x) == :((19220+28830x+48050*x^2)^-1*(1659+5530x)+1//310*(2+3x+5*x^2)^-2*(77+143x)+1106//29791*31^(1/2)*arctan(1//31*31^(1/2)*(3+10x)))
@test integrate((2+3x+5*x^2)^4*(3+-1x+2*x^2)^2, x) == :(144x+384*x^2+1571*x^10+1838*x^4+3315*x^8+875//3*x^12+2500//13*x^13+3016//3*x^3+10771//3*x^6+11525//11*x^11+14801//5*x^5+24859//9*x^9+27763//7*x^7)
@test integrate((2+3x+5*x^2)^3*(3+-1x+2*x^2)^2, x) == :(40*x^10+72x+138*x^2+444*x^7+449*x^6+500//11*x^11+914//3*x^3+1615//4*x^4+1863//8*x^8+1865//9*x^9+2693//5*x^5)
@test integrate((2+3x+5*x^2)^2*(3+-1x+2*x^2)^2, x) == :(36x+42*x^2+59*x^4+78*x^5+5//2*x^8+86//3*x^6+100//9*x^9+241//3*x^3+321//7*x^7)
@test integrate((3+-1x+2*x^2)^2*(2+3x+5*x^2), x) == :(18x+-4//3*x^6+1//4*x^4+15//2*x^2+20//7*x^7+53//3*x^3+61//5*x^5)
@test integrate((2+3x+5*x^2)^-1*(3+-1x+2*x^2)^2, x) == :(-1573//1250*log(2+3x+5*x^2)+-16//25*x^2+4//15*x^3+381//125*x+8349//19375*31^(1/2)*arctan(1//31*31^(1/2)*(3+10x)))
@test integrate((2+3x+5*x^2)^-2*(3+-1x+2*x^2)^2, x) == :(-22//125*log(2+3x+5*x^2)+4//25*x+(7750+11625x+19375*x^2)^-1*(7381+8349x)+41932//120125*31^(1/2)*arctan(1//31*31^(1/2)*(3+10x)))
@test integrate((2+3x+5*x^2)^-3*(3+-1x+2*x^2)^2, x) == :((480500+720750x+1201250*x^2)^-1*(193127+502810x)+1//7750*(2+3x+5*x^2)^-2*(7381+8349x)+4330//29791*31^(1/2)*arctan(1//31*31^(1/2)*(3+10x)))
@test integrate((2+3x+5*x^2)^-4*(3+-1x+2*x^2)^2, x) == :((297910+446865x+744775*x^2)^-1*(50064+166880x)+1//11625*(2+3x+5*x^2)^-3*(7381+8349x)+1//120125*(2+3x+5*x^2)^-2*(50369+132660x)+66752//923521*31^(1/2)*arctan(1//31*31^(1/2)*(3+10x)))
@test integrate((2+3x+5*x^2)^4*(3+-1x+2*x^2)^3, x) == :(432x+1080*x^2+2856*x^3+5144*x^4+1000//3*x^15+2250//7*x^14+27050//13*x^13+30395//12*x^12+43083//5*x^5+64529//6*x^6+68583//11*x^11+75311//10*x^10+91349//7*x^7+94881//8*x^8+103583//9*x^9)
@test integrate((2+3x+5*x^2)^3*(3+-1x+2*x^2)^3, x) == :(25*x^12+216x+378*x^2+870*x^3+1000//13*x^13+2873//2*x^6+3061//10*x^10+3316//3*x^9+4483//4*x^4+4830//11*x^11+7869//8*x^8+8292//5*x^5+12016//7*x^7)
@test integrate((2+3x+5*x^2)^2*(3+-1x+2*x^2)^3, x) == :(-6*x^10+108x+108*x^2+237*x^3+83//8*x^8+200//11*x^11+299//3*x^6+635//4*x^4+922//9*x^9+1416//5*x^5+1571//7*x^7)
@test integrate((3+-1x+2*x^2)^3*(2+3x+5*x^2), x) == :(-5*x^4+54x+60*x^3+-83//6*x^6+-9//2*x^8+27//2*x^2+40//9*x^9+190//7*x^7+288//5*x^5)
@test integrate((2+3x+5*x^2)^-1*(3+-1x+2*x^2)^3, x) == :(-158389//31250*log(2+3x+5*x^2)+-7451//1250*x^2+-21//25*x^4+8//25*x^5+1222//375*x^3+49508//3125*x+328757//484375*31^(1/2)*arctan(1//31*31^(1/2)*(3+10x)))
@test integrate((2+3x+5*x^2)^-2*(3+-1x+2*x^2)^3, x) == :(-10769//6250*log(2+3x+5*x^2)+-54//125*x^2+8//75*x^3+1466//625*x+(193750+290625x+484375*x^2)^-1*(589633+328757x)+3819607//3003125*31^(1/2)*arctan(1//31*31^(1/2)*(3+10x)))
@test integrate((2+3x+5*x^2)^-3*(3+-1x+2*x^2)^3, x) == :(-66//625*log(2+3x+5*x^2)+8//125*x+(12012500+18018750x+30031250*x^2)^-1*(22794101+41483640x)+1//193750*(2+3x+5*x^2)^-2*(589633+328757x)+11341176//18619375*31^(1/2)*arctan(1//31*31^(1/2)*(3+10x)))
@test integrate((2+3x+5*x^2)^4*(3+-1x+2*x^2)^-1, x) == :(-28747//128*x^2+-21229//96*x^3+625//14*x^7+1855//8*x^5+3625//24*x^6+6245//64*x^4+122691//128*x+307461//512*log(3+-1x+2*x^2)+1156639//5888*23^(1/2)*arctan(1//23*23^(1/2)*(1+-4x)))
@test integrate((2+3x+5*x^2)^3*(3+-1x+2*x^2)^-1, x) == :(-4795//32*x+-829//32*x^2+25//2*x^5+575//16*x^4+965//24*x^3+1331//128*log(3+-1x+2*x^2)+-59895//1472*23^(1/2)*arctan(1//23*23^(1/2)*(1+-4x)))
@test integrate((2+3x+5*x^2)^2*(3+-1x+2*x^2)^-1, x) == :(-363//32*log(3+-1x+2*x^2)+25//6*x^3+51//8*x+85//8*x^2+847//368*23^(1/2)*arctan(1//23*23^(1/2)*(1+-4x)))
@test integrate((3+-1x+2*x^2)^-1*(2+3x+5*x^2), x) == :(5//2*x+11//8*log(3+-1x+2*x^2)+33//92*23^(1/2)*arctan(1//23*23^(1/2)*(1+-4x)))
@test integrate((2+3x+5*x^2)^-1*(3+-1x+2*x^2)^-1, x) == :(-1//44*log(3+-1x+2*x^2)+1//44*log(2+3x+5*x^2)+3//506*23^(1/2)*arctan(1//23*23^(1/2)*(1+-4x))+13//682*31^(1/2)*arctan(1//31*31^(1/2)*(3+10x)))
@test integrate((2+3x+5*x^2)^-2*(3+-1x+2*x^2)^-1, x) == :(-3//968*log(2+3x+5*x^2)+3//968*log(3+-1x+2*x^2)+(1364+2046x+3410*x^2)^-1*(4+65x)+7//11132*23^(1/2)*arctan(1//23*23^(1/2)*(1+-4x))+2891//465124*31^(1/2)*arctan(1//31*31^(1/2)*(3+10x)))
@test integrate((2+3x+5*x^2)^-3*(3+-1x+2*x^2)^-1, x) == :(-1//21296*log(3+-1x+2*x^2)+1//21296*log(2+3x+5*x^2)+(930248+1395372x+2325620*x^2)^-1*(7923+21605x)+-45//244904*23^(1/2)*arctan(1//23*23^(1/2)*(1+-4x))+1//1364*(2+3x+5*x^2)^-2*(4+65x)+847793//317214568*31^(1/2)*arctan(1//31*31^(1/2)*(3+10x)))
@test integrate((2+3x+5*x^2)^4*(3+-1x+2*x^2)^-2, x) == :(-89359//64*x+-30613//128*log(3+-1x+2*x^2)+-1185//8*x^2+125//4*x^5+2125//16*x^4+9775//48*x^3+-1*(8832+-2944x+5888*x^2)^-1*(1478741+1156639x)+-13292697//33856*23^(1/2)*arctan(1//23*23^(1/2)*(1+-4x)))
@test integrate((2+3x+5*x^2)^3*(3+-1x+2*x^2)^-2, x) == :(-2057//32*log(3+-1x+2*x^2)+125//12*x^3+175//4*x^2+915//16*x+-1*(2208+-736x+1472*x^2)^-1*(22627+-59895x)+223971//8464*23^(1/2)*arctan(1//23*23^(1/2)*(1+-4x)))
@test integrate((2+3x+5*x^2)^2*(3+-1x+2*x^2)^-2, x) == :(25//4*x+55//8*log(3+-1x+2*x^2)+(552+-184x+368*x^2)^-1*(2299+-847x)+1859//2116*23^(1/2)*arctan(1//23*23^(1/2)*(1+-4x)))
@test integrate((3+-1x+2*x^2)^-2*(2+3x+5*x^2), x) == :((138+-46x+92*x^2)^-1*(-55+-33x)+-82//529*23^(1/2)*arctan(1//23*23^(1/2)*(1+-4x)))
@test integrate((2+3x+5*x^2)^-1*(3+-1x+2*x^2)^-2, x) == :(-13//968*log(3+-1x+2*x^2)+13//968*log(2+3x+5*x^2)+(1518+-506x+1012*x^2)^-1*(13+-6x)+69//15004*31^(1/2)*arctan(1//31*31^(1/2)*(3+10x))+241//256036*23^(1/2)*arctan(1//23*23^(1/2)*(1+-4x)))
@test integrate((2+3x+5*x^2)^-2*(3+-1x+2*x^2)^-2, x) == :(-19//10648*log(2+3x+5*x^2)+19//10648*log(3+-1x+2*x^2)+(345092+517638x+862730*x^2)^-1*(-2925+3425x)+2769//2816396*23^(1/2)*arctan(1//23*23^(1/2)*(1+-4x))+12643//5116364*31^(1/2)*arctan(1//31*31^(1/2)*(3+10x))+(2+3x+5*x^2)^-1*(1518+-506x+1012*x^2)^-1*(13+-6x))
@test integrate((2+3x+5*x^2)^-3*(3+-1x+2*x^2)^-2, x) == :(-97//468512*log(2+3x+5*x^2)+97//468512*log(3+-1x+2*x^2)+(470705488+706058232x+1176763720*x^2)^-1*(1765599+3996965x)+-25557//123921424*23^(1/2)*arctan(1//23*23^(1/2)*(1+-4x))+1//690184*(2+3x+5*x^2)^-2*(-9446+5765x)+4464079//6978720496*31^(1/2)*arctan(1//31*31^(1/2)*(3+10x))+(2+3x+5*x^2)^-2*(1518+-506x+1012*x^2)^-1*(13+-6x))
@test integrate((2+3x+5*x^2)^4*(3+-1x+2*x^2)^-3, x) == :(-13915//64*log(3+-1x+2*x^2)+625//24*x^3+2725//8*x+4875//32*x^2+(406272+-135424x+270848*x^2)^-1*(6959799+101715020x)+-1//5888*(3+-1x+2*x^2)^-2*(1478741+1156639x)+63799791//389344*23^(1/2)*arctan(1//23*23^(1/2)*(1+-4x)))
@test integrate((2+3x+5*x^2)^3*(3+-1x+2*x^2)^-3, x) == :(125//8*x+825//32*log(3+-1x+2*x^2)+(101568+-33856x+67712*x^2)^-1*(2564353+-1552188x)+-1//1472*(3+-1x+2*x^2)^-2*(22627+-59895x)+165099//194672*23^(1/2)*arctan(1//23*23^(1/2)*(1+-4x)))
@test integrate((2+3x+5*x^2)^2*(3+-1x+2*x^2)^-3, x) == :(-1*(25392+-8464x+16928*x^2)^-1*(53625+18260x)+-4330//12167*23^(1/2)*arctan(1//23*23^(1/2)*(1+-4x))+1//368*(3+-1x+2*x^2)^-2*(2299+-847x))
@test integrate((3+-1x+2*x^2)^-3*(2+3x+5*x^2), x) == :(-1*(6348+-2116x+4232*x^2)^-1*(131+-524x)+-262//12167*23^(1/2)*arctan(1//23*23^(1/2)*(1+-4x))+1//92*(3+-1x+2*x^2)^-2*(-55+-33x))
@test integrate((2+3x+5*x^2)^-1*(3+-1x+2*x^2)^-3, x) == :(-119//21296*log(3+-1x+2*x^2)+119//21296*log(2+3x+5*x^2)+(768108+-256036x+512072*x^2)^-1*(3625+-746x)+-53403//129554216*23^(1/2)*arctan(1//23*23^(1/2)*(1+-4x))+1//1012*(3+-1x+2*x^2)^-2*(13+-6x)+247//330088*31^(1/2)*arctan(1//31*31^(1/2)*(3+10x)))
@test integrate((2+3x+5*x^2)^-2*(3+-1x+2*x^2)^-3, x) == :(-181//468512*log(2+3x+5*x^2)+181//468512*log(3+-1x+2*x^2)+(349233104+523849656x+873082760*x^2)^-1*(-2328909+-252815x)+246757//225120016*31^(1/2)*arctan(1//31*31^(1/2)*(3+10x))+2038497//2850192752*23^(1/2)*arctan(1//23*23^(1/2)*(1+-4x))+(2+3x+5*x^2)^-1*(1536216+-512072x+1024144*x^2)^-1*(9665+-1446x)+1//1012*(2+3x+5*x^2)^-1*(3+-1x+2*x^2)^-2*(13+-6x))
@test integrate((2+3x+5*x^2)^-3*(3+-1x+2*x^2)^-3, x) == :(-405//1288408*log(2+3x+5*x^2)+405//1288408*log(3+-1x+2*x^2)+(29772122116+44658183174x+74430305290*x^2)^-1*(39274590+107106525x)+-880575//7838030068*23^(1/2)*arctan(1//23*23^(1/2)*(1+-4x))+1//87308276*(2+3x+5*x^2)^-2*(-1118535+-385100x)+2768835//19191481364*31^(1/2)*arctan(1//31*31^(1/2)*(3+10x))+(2+3x+5*x^2)^-2*(192027+-64009x+128018*x^2)^-1*(1510+-175x)+1//1012*(2+3x+5*x^2)^-2*(3+-1x+2*x^2)^-2*(13+-6x))
@test integrate((2+3x+5*x^2)^4*(3+-1x+2*x^2)^(1/2), x) == :(27185733541//440401920*(3+-1x+2*x^2)^3//2+-8267844569//268435456*2^(1/2)*arcsinh(1//23*23^(1/2)*(1+-4x))+-83948353//2293760*x^2*(3+-1x+2*x^2)^3//2+-1//67108864*(3+-1x+2*x^2)^(1/2)*(359471503+-1437886012x)+125//4*x^7*(3+-1x+2*x^2)^3//2+14125//144*x^6*(3+-1x+2*x^2)^3//2+233225//1536*x^5*(3+-1x+2*x^2)^3//2+4796405//43008*x^4*(3+-1x+2*x^2)^3//2+8325631//1032192*x^3*(3+-1x+2*x^2)^3//2+804243809//36700160*x*(3+-1x+2*x^2)^3//2)
@test integrate((2+3x+5*x^2)^3*(3+-1x+2*x^2)^(1/2), x) == :(-22548119//4587520*(3+-1x+2*x^2)^3//2+-155620231//8388608*2^(1/2)*arcsinh(1//23*23^(1/2)*(1+-4x))+-9627393//1146880*x*(3+-1x+2*x^2)^3//2+-1//2097152*(3+-1x+2*x^2)^(1/2)*(6766097+-27064388x)+125//16*x^5*(3+-1x+2*x^2)^3//2+8825//448*x^4*(3+-1x+2*x^2)^3//2+247435//10752*x^3*(3+-1x+2*x^2)^3//2+531681//71680*x^2*(3+-1x+2*x^2)^3//2)
@test integrate((2+3x+5*x^2)^2*(3+-1x+2*x^2)^(1/2), x) == :(-2107//3072*(3+-1x+2*x^2)^3//2+1//16384*(3+-1x+2*x^2)^(1/2)*(12371+-49484x)+25//12*x^3*(3+-1x+2*x^2)^3//2+63//16*x^2*(3+-1x+2*x^2)^3//2+769//256*x*(3+-1x+2*x^2)^3//2+284533//65536*2^(1/2)*arcsinh(1//23*23^(1/2)*(1+-4x)))
@test integrate((3+-1x+2*x^2)^(1/2)*(2+3x+5*x^2), x) == :(73//96*(3+-1x+2*x^2)^3//2+(3+-1x+2*x^2)^(1/2)*(-81//512+81//128*x)+-1863//2048*2^(1/2)*arcsinh(1//23*23^(1/2)*(1+-4x))+5//8*x*(3+-1x+2*x^2)^3//2)
@test integrate((2+3x+5*x^2)^-1*(3+-1x+2*x^2)^(1/2), x) == :(-1//5*2^(1/2)*arcsinh(1//23*23^(1/2)*(1+-4x))+-1//5*(-143//31+110//31*2^(1/2))^(1/2)*arctanh(11^(1/2)*(-806+620*2^(1/2))^-1//2*(3+-1x+2*x^2)^-1//2*(6+-7*2^(1/2)+x*(20+-13*2^(1/2))))+1//5*(143//31+110//31*2^(1/2))^(1/2)*arctan(11^(1/2)*(806+620*2^(1/2))^-1//2*(3+-1x+2*x^2)^-1//2*(6+7*2^(1/2)+x*(20+13*2^(1/2)))))
@test integrate((2+3x+5*x^2)^-2*(3+-1x+2*x^2)^(1/2), x) == :(-1//62*(-70517//682+24971//341*2^(1/2))^(1/2)*arctanh(11^(1/2)*(-2186027+1548202*2^(1/2))^-1//2*(3+-1x+2*x^2)^-1//2*(419+-277*2^(1/2)+x*(973+-696*2^(1/2))))+1//62*(70517//682+24971//341*2^(1/2))^(1/2)*arctan(11^(1/2)*(2186027+1548202*2^(1/2))^-1//2*(3+-1x+2*x^2)^-1//2*(419+277*2^(1/2)+x*(973+696*2^(1/2))))+(3+-1x+2*x^2)^(1/2)*(62+93x+155*x^2)^-1*(3+10x))
@test integrate((2+3x+5*x^2)^-3*(3+-1x+2*x^2)^(1/2), x) == :(-1//169136*(-112285869463//682+39699690370//341*2^(1/2))^(1/2)*arctanh(11^(1/2)*(-3480861953353+2461380802940*2^(1/2))^-1//2*(3+-1x+2*x^2)^-1//2*(509587+-362788*2^(1/2)+x*(1235163+-872375*2^(1/2))))+1//169136*(112285869463//682+39699690370//341*2^(1/2))^(1/2)*arctan(11^(1/2)*(3480861953353+2461380802940*2^(1/2))^-1//2*(3+-1x+2*x^2)^-1//2*(509587+362788*2^(1/2)+x*(1235163+872375*2^(1/2))))+(3+-1x+2*x^2)^(1/2)*(169136+253704x+422840*x^2)^-1*(3464+13665x)+1//62*(2+3x+5*x^2)^-2*(3+-1x+2*x^2)^(1/2)*(3+10x))
@test integrate((2+3x+5*x^2)^4*(3+-1x+2*x^2)^3//2, x) == :(2124689283//146800640*(3+-1x+2*x^2)^5//2+-606427533063//8589934592*2^(1/2)*arcsinh(1//23*23^(1/2)*(1+-4x))+-56422489//8257536*x^2*(3+-1x+2*x^2)^5//2+-1//134217728*(3+-1x+2*x^2)^3//2*(382121949+-1528487796x)+-1//2147483648*(3+-1x+2*x^2)^(1/2)*(26366414481+-105465657924x)+625//24*x^7*(3+-1x+2*x^2)^5//2+7625//96*x^6*(3+-1x+2*x^2)^5//2+95165//768*x^5*(3+-1x+2*x^2)^5//2+941905//9216*x^4*(3+-1x+2*x^2)^5//2+10444117//294912*x^3*(3+-1x+2*x^2)^5//2+48669967//22020096*x*(3+-1x+2*x^2)^5//2)
@test integrate((2+3x+5*x^2)^3*(3+-1x+2*x^2)^3//2, x) == :(-4625907//2293760*(3+-1x+2*x^2)^5//2+-1059790665//134217728*2^(1/2)*arcsinh(1//23*23^(1/2)*(1+-4x))+-81685//114688*x*(3+-1x+2*x^2)^5//2+-1//2097152*(3+-1x+2*x^2)^3//2*(667795+-2671180x)+-1//33554432*(3+-1x+2*x^2)^(1/2)*(46077855+-184311420x)+25//4*x^5*(3+-1x+2*x^2)^5//2+725//48*x^4*(3+-1x+2*x^2)^5//2+27785//1536*x^3*(3+-1x+2*x^2)^5//2+384739//43008*x^2*(3+-1x+2*x^2)^5//2)
@test integrate((2+3x+5*x^2)^2*(3+-1x+2*x^2)^3//2, x) == :(73861//215040*(3+-1x+2*x^2)^5//2+1//196608*(3+-1x+2*x^2)^3//2*(24293+-97172x)+1//1048576*(3+-1x+2*x^2)^(1/2)*(558739+-2234956x)+25//16*x^3*(3+-1x+2*x^2)^5//2+1235//448*x^2*(3+-1x+2*x^2)^5//2+24499//10752*x*(3+-1x+2*x^2)^5//2+12850997//4194304*2^(1/2)*arcsinh(1//23*23^(1/2)*(1+-4x)))
@test integrate((3+-1x+2*x^2)^3//2*(2+3x+5*x^2), x) == :(107//240*(3+-1x+2*x^2)^5//2+-94691//32768*2^(1/2)*arcsinh(1//23*23^(1/2)*(1+-4x))+-1//1536*(3+-1x+2*x^2)^3//2*(179+-716x)+-1//8192*(3+-1x+2*x^2)^(1/2)*(4117+-16468x)+5//12*x*(3+-1x+2*x^2)^5//2)
@test integrate((2+3x+5*x^2)^-1*(3+-1x+2*x^2)^3//2, x) == :(-2203//2000*2^(1/2)*arcsinh(1//23*23^(1/2)*(1+-4x))+-11//125*(-2717//31+5500//31*2^(1/2))^(1/2)*arctanh(11^(1/2)*(-15314+31000*2^(1/2))^-1//2*(3+-1x+2*x^2)^-1//2*(8+-61*2^(1/2)+x*(130+-69*2^(1/2))))+-1//100*(3+-1x+2*x^2)^(1/2)*(49+-20x)+11//125*(2717//31+5500//31*2^(1/2))^(1/2)*arctan(11^(1/2)*(15314+31000*2^(1/2))^-1//2*(3+-1x+2*x^2)^-1//2*(8+61*2^(1/2)+x*(130+69*2^(1/2)))))
@test integrate((2+3x+5*x^2)^-2*(3+-1x+2*x^2)^3//2, x) == :(-2//25*2^(1/2)*arcsinh(1//23*23^(1/2)*(1+-4x))+-1//1550*(-34862663//31+24918850//31*2^(1/2))^(1/2)*arctanh(11^(1/2)*(-196498646+140451700*2^(1/2))^-1//2*(3+-1x+2*x^2)^-1//2*(3514+-2963*2^(1/2)+x*(9440+-6477*2^(1/2))))+1//155*(3+-1x+2*x^2)^(1/2)*(16+-20x)+1//1550*(34862663//31+24918850//31*2^(1/2))^(1/2)*arctan(11^(1/2)*(196498646+140451700*2^(1/2))^-1//2*(3+-1x+2*x^2)^-1//2*(3514+2963*2^(1/2)+x*(9440+6477*2^(1/2))))+(3+-1x+2*x^2)^3//2*(62+93x+155*x^2)^-1*(3+10x))
@test integrate((2+3x+5*x^2)^-3*(3+-1x+2*x^2)^3//2, x) == :(-3//7688*(-366990269//682+129754513//341*2^(1/2))^(1/2)*arctanh(11^(1/2)*(-11376698339+8044779806*2^(1/2))^-1//2*(3+-1x+2*x^2)^-1//2*(29367+-20575*2^(1/2)+x*(70517+-49942*2^(1/2))))+3//7688*(366990269//682+129754513//341*2^(1/2))^(1/2)*arctan(11^(1/2)*(11376698339+8044779806*2^(1/2))^-1//2*(3+-1x+2*x^2)^-1//2*(29367+20575*2^(1/2)+x*(70517+49942*2^(1/2))))+(3+-1x+2*x^2)^(1/2)*(7688+11532x+19220*x^2)^-1*(831+2088x)+1//62*(2+3x+5*x^2)^-2*(3+-1x+2*x^2)^3//2*(3+10x))
@test integrate((2+3x+5*x^2)^4*(3+-1x+2*x^2)^5//2, x) == :(25250178739//5725224960*(3+-1x+2*x^2)^7//2+-14641852251147//137438953472*2^(1/2)*arcsinh(1//23*23^(1/2)*(1+-4x))+-1//335544320*(3+-1x+2*x^2)^5//2*(401135647+-1604542588x)+-1//2147483648*(3+-1x+2*x^2)^3//2*(9226119881+-36904479524x)+-1//34359738368*(3+-1x+2*x^2)^(1/2)*(636602271789+-2546409087156x)+625//28*x^7*(3+-1x+2*x^2)^7//2+13875//208*x^6*(3+-1x+2*x^2)^7//2+1046225//9984*x^5*(3+-1x+2*x^2)^7//2+3684995//39936*x^4*(3+-1x+2*x^2)^7//2+23460839//532480*x^3*(3+-1x+2*x^2)^7//2+112244125//122683392*x*(3+-1x+2*x^2)^7//2+122595067//19169280*x^2*(3+-1x+2*x^2)^7//2)
@test integrate((2+3x+5*x^2)^3*(3+-1x+2*x^2)^5//2, x) == :(-1696165//2752512*(3+-1x+2*x^2)^7//2+-10569777075//4294967296*2^(1/2)*arcsinh(1//23*23^(1/2)*(1+-4x))+-1//2097152*(3+-1x+2*x^2)^5//2*(57915+-231660x)+-1//67108864*(3+-1x+2*x^2)^3//2*(6660225+-26640900x)+-1//1073741824*(3+-1x+2*x^2)^(1/2)*(459555525+-1838222100x)+125//24*x^5*(3+-1x+2*x^2)^7//2+1175//96*x^4*(3+-1x+2*x^2)^7//2+3823//256*x^3*(3+-1x+2*x^2)^7//2+80483//9216*x^2*(3+-1x+2*x^2)^7//2+509257//294912*x*(3+-1x+2*x^2)^7//2)
@test integrate((2+3x+5*x^2)^2*(3+-1x+2*x^2)^5//2, x) == :(23225//43008*(3+-1x+2*x^2)^7//2+-94111745//67108864*2^(1/2)*arcsinh(1//23*23^(1/2)*(1+-4x))+-1//98304*(3+-1x+2*x^2)^5//2*(1547+-6188x)+-1//3145728*(3+-1x+2*x^2)^3//2*(177905+-711620x)+-1//16777216*(3+-1x+2*x^2)^(1/2)*(4091815+-16367260x)+5//4*x^3*(3+-1x+2*x^2)^7//2+305//144*x^2*(3+-1x+2*x^2)^7//2+8467//4608*x*(3+-1x+2*x^2)^7//2)
@test integrate((3+-1x+2*x^2)^5//2*(2+3x+5*x^2), x) == :(141//448*(3+-1x+2*x^2)^7//2+-16851295//2097152*2^(1/2)*arcsinh(1//23*23^(1/2)*(1+-4x))+-1//3072*(3+-1x+2*x^2)^5//2*(277+-1108x)+-1//98304*(3+-1x+2*x^2)^3//2*(31855+-127420x)+-1//524288*(3+-1x+2*x^2)^(1/2)*(732665+-2930660x)+5//16*x*(3+-1x+2*x^2)^7//2)
@test integrate((2+3x+5*x^2)^-1*(3+-1x+2*x^2)^5//2, x) == :(-7216203//1600000*2^(1/2)*arcsinh(1//23*23^(1/2)*(1+-4x))+-121//3125*(-170027//31+275000//31*2^(1/2))^(1/2)*arctan(11^(1/2)*(-958334+1550000*2^(1/2))^-1//2*(3+-1x+2*x^2)^-1//2*(196+-443*2^(1/2)+-1*x*(690+247*2^(1/2))))+-1//600*(3+-1x+2*x^2)^3//2*(103+-60x)+-1//80000*(3+-1x+2*x^2)^(1/2)*(226249+-99620x)+121//3125*(170027//31+275000//31*2^(1/2))^(1/2)*arctanh(11^(1/2)*(958334+1550000*2^(1/2))^-1//2*(3+-1x+2*x^2)^-1//2*(196+443*2^(1/2)+-1*x*(690+-247*2^(1/2)))))
@test integrate((2+3x+5*x^2)^-2*(3+-1x+2*x^2)^5//2, x) == :(-4799//5000*2^(1/2)*arcsinh(1//23*23^(1/2)*(1+-4x))+-11//38750*(-2469614213//31+2139362500//31*2^(1/2))^(1/2)*arctanh(11^(1/2)*(-13919643746+12058225000*2^(1/2))^-1//2*(3+-1x+2*x^2)^-1//2*(21136+-33287*2^(1/2)+x*(87710+-54423*2^(1/2))))+-1//7750*(3+-1x+2*x^2)^(1/2)*(1277+2240x)+1//155*(3+-1x+2*x^2)^3//2*(16+-20x)+11//38750*(2469614213//31+2139362500//31*2^(1/2))^(1/2)*arctan(11^(1/2)*(13919643746+12058225000*2^(1/2))^-1//2*(3+-1x+2*x^2)^-1//2*(21136+33287*2^(1/2)+x*(87710+54423*2^(1/2))))+(3+-1x+2*x^2)^5//2*(62+93x+155*x^2)^-1*(3+10x))
@test integrate((2+3x+5*x^2)^-3*(3+-1x+2*x^2)^5//2, x) == :(-4//125*2^(1/2)*arcsinh(1//23*23^(1/2)*(1+-4x))+1//48050*(3+-1x+2*x^2)^(1/2)*(11359+-12920x)+(3+-1x+2*x^2)^3//2*(7688+11532x+19220*x^2)^-1*(769+2336x)+-1//29791000*(-11+44*2^(1/2))^(1/2)*(2937349+-1978861*2^(1/2))*arctanh(11^(1/2)*(-218922973868534+154928828417500*2^(1/2))^-1//2*(3+-1x+2*x^2)^-1//2*(3957722+-2937349*2^(1/2)+x*(9832420+-6895071*2^(1/2))))+1//62*(2+3x+5*x^2)^-2*(3+-1x+2*x^2)^5//2*(3+10x)+1//29791000*(11+44*2^(1/2))^(1/2)*(2937349+1978861*2^(1/2))*arctan(11^(1/2)*(218922973868534+154928828417500*2^(1/2))^-1//2*(3+-1x+2*x^2)^-1//2*(3957722+2937349*2^(1/2)+x*(9832420+6895071*2^(1/2)))))
@test integrate((2+3x+5*x^2)^4*(3+-1x+2*x^2)^-1//2, x) == :(16493087661//29360128*(3+-1x+2*x^2)^(1/2)+-19750457//229376*x^3*(3+-1x+2*x^2)^(1/2)+-15428243//131072*x^2*(3+-1x+2*x^2)^(1/2)+625//16*x^7*(3+-1x+2*x^2)^(1/2)+57375//448*x^6*(3+-1x+2*x^2)^(1/2)+686531//6144*x^4*(3+-1x+2*x^2)^(1/2)+2116475//10752*x^5*(3+-1x+2*x^2)^(1/2)+1572007407//7340032*x*(3+-1x+2*x^2)^(1/2)+2899366573//16777216*2^(1/2)*arcsinh(1//23*23^(1/2)*(1+-4x)))
@test integrate((2+3x+5*x^2)^3*(3+-1x+2*x^2)^-1//2, x) == :(-203373//32768*(3+-1x+2*x^2)^(1/2)+-9267707//131072*2^(1/2)*arcsinh(1//23*23^(1/2)*(1+-4x))+-372783//8192*x*(3+-1x+2*x^2)^(1/2)+-3387//1024*x^2*(3+-1x+2*x^2)^(1/2)+125//12*x^5*(3+-1x+2*x^2)^(1/2)+1355//48*x^4*(3+-1x+2*x^2)^(1/2)+8185//256*x^3*(3+-1x+2*x^2)^(1/2))
@test integrate((2+3x+5*x^2)^2*(3+-1x+2*x^2)^-1//2, x) == :(-11373//1024*(3+-1x+2*x^2)^(1/2)+25//8*x^3*(3+-1x+2*x^2)^(1/2)+655//96*x^2*(3+-1x+2*x^2)^(1/2)+3443//768*x*(3+-1x+2*x^2)^(1/2)+30725//4096*2^(1/2)*arcsinh(1//23*23^(1/2)*(1+-4x)))
@test integrate((3+-1x+2*x^2)^-1//2*(2+3x+5*x^2), x) == :(39//16*(3+-1x+2*x^2)^(1/2)+5//4*x*(3+-1x+2*x^2)^(1/2)+17//64*2^(1/2)*arcsinh(1//23*23^(1/2)*(1+-4x)))
@test integrate((2+3x+5*x^2)^-1*(3+-1x+2*x^2)^-1//2, x) == :((13//682+5//341*2^(1/2))^(1/2)*arctan(11^(1/2)*(403+310*2^(1/2))^-1//2*(3+-1x+2*x^2)^-1//2*(7+3*2^(1/2)+x*(13+10*2^(1/2))))+-1*(-13//682+5//341*2^(1/2))^(1/2)*arctanh(11^(1/2)*(-403+310*2^(1/2))^-1//2*(3+-1x+2*x^2)^-1//2*(7+-3*2^(1/2)+x*(13+-10*2^(1/2)))))
@test integrate((2+3x+5*x^2)^-2*(3+-1x+2*x^2)^-1//2, x) == :(-1//1364*(-2343727//682+839350//341*2^(1/2))^(1/2)*arctanh(11^(1/2)*(-72655537+52039700*2^(1/2))^-1//2*(3+-1x+2*x^2)^-1//2*(2119+-1816*2^(1/2)+x*(5751+-3935*2^(1/2))))+1//1364*(2343727//682+839350//341*2^(1/2))^(1/2)*arctan(11^(1/2)*(72655537+52039700*2^(1/2))^-1//2*(3+-1x+2*x^2)^-1//2*(2119+1816*2^(1/2)+x*(5751+3935*2^(1/2))))+(3+-1x+2*x^2)^(1/2)*(1364+2046x+3410*x^2)^-1*(4+65x))
@test integrate((2+3x+5*x^2)^-3*(3+-1x+2*x^2)^-1//2, x) == :(-25//3720992*(-6414867847//682+2268187300//341*2^(1/2))^(1/2)*arctanh(11^(1/2)*(-198860903257+140627612600*2^(1/2))^-1//2*(3+-1x+2*x^2)^-1//2*(123161+-85754*2^(1/2)+x*(294669+-208915*2^(1/2))))+25//3720992*(6414867847//682+2268187300//341*2^(1/2))^(1/2)*arctan(11^(1/2)*(198860903257+140627612600*2^(1/2))^-1//2*(3+-1x+2*x^2)^-1//2*(123161+85754*2^(1/2)+x*(294669+208915*2^(1/2))))+(3+-1x+2*x^2)^(1/2)*(3720992+5581488x+9302480*x^2)^-1*(26794+86265x)+1//1364*(2+3x+5*x^2)^-2*(3+-1x+2*x^2)^(1/2)*(4+65x))
@test integrate((2+3x+5*x^2)^4*(3+-1x+2*x^2)^-3//2, x) == :(-31009685//65536*(3+-1x+2*x^2)^(1/2)+-310445587//262144*2^(1/2)*arcsinh(1//23*23^(1/2)*(1+-4x))+-8992487//16384*x*(3+-1x+2*x^2)^(1/2)+-111315//2048*x^2*(3+-1x+2*x^2)^(1/2)+-1//1472*(3+-1x+2*x^2)^-1//2*(1478741+1156639x)+625//24*x^5*(3+-1x+2*x^2)^(1/2)+10075//96*x^4*(3+-1x+2*x^2)^(1/2)+79425//512*x^3*(3+-1x+2*x^2)^(1/2))
@test integrate((2+3x+5*x^2)^3*(3+-1x+2*x^2)^-3//2, x) == :(-181561//2048*(3+-1x+2*x^2)^(1/2)+-1//368*(3+-1x+2*x^2)^-1//2*(22627+-59895x)+125//16*x^3*(3+-1x+2*x^2)^(1/2)+1825//64*x^2*(3+-1x+2*x^2)^(1/2)+15565//512*x*(3+-1x+2*x^2)^(1/2)+1168881//8192*2^(1/2)*arcsinh(1//23*23^(1/2)*(1+-4x)))
@test integrate((2+3x+5*x^2)^2*(3+-1x+2*x^2)^-3//2, x) == :(415//32*(3+-1x+2*x^2)^(1/2)+-223//128*2^(1/2)*arcsinh(1//23*23^(1/2)*(1+-4x))+1//92*(3+-1x+2*x^2)^-1//2*(2299+-847x)+25//8*x*(3+-1x+2*x^2)^(1/2))
@test integrate((3+-1x+2*x^2)^-3//2*(2+3x+5*x^2), x) == :(-5//4*2^(1/2)*arcsinh(1//23*23^(1/2)*(1+-4x))+1//23*(3+-1x+2*x^2)^-1//2*(-55+-33x))
@test integrate((2+3x+5*x^2)^-1*(3+-1x+2*x^2)^-3//2, x) == :(-1//22*(-247//682+250//341*2^(1/2))^(1/2)*arctanh(11^(1/2)*(-7657+15500*2^(1/2))^-1//2*(3+-1x+2*x^2)^-1//2*(61+-4*2^(1/2)+x*(69+-65*2^(1/2))))+1//22*(247//682+250//341*2^(1/2))^(1/2)*arctan(11^(1/2)*(7657+15500*2^(1/2))^-1//2*(3+-1x+2*x^2)^-1//2*(61+4*2^(1/2)+x*(69+65*2^(1/2))))+1//253*(3+-1x+2*x^2)^-1//2*(13+-6x))
@test integrate((2+3x+5*x^2)^-2*(3+-1x+2*x^2)^-3//2, x) == :(-1//30008*(-129694447//682+51887500//341*2^(1/2))^(1/2)*arctanh(11^(1/2)*(-4020527857+3217025000*2^(1/2))^-1//2*(3+-1x+2*x^2)^-1//2*(12611+-16454*2^(1/2)+x*(45519+-29065*2^(1/2))))+-1//345092*(3+-1x+2*x^2)^-1//2*(6315+-2306x)+1//30008*(129694447//682+51887500//341*2^(1/2))^(1/2)*arctan(11^(1/2)*(4020527857+3217025000*2^(1/2))^-1//2*(3+-1x+2*x^2)^-1//2*(12611+16454*2^(1/2)+x*(45519+29065*2^(1/2))))+1//682*(2+3x+5*x^2)^-1*(3+-1x+2*x^2)^-1//2*(4+65x))
@test integrate((2+3x+5*x^2)^-3*(3+-1x+2*x^2)^-3//2, x) == :(-3//81861824*(-13874275807943//682+4909869325000//341*2^(1/2))^(1/2)*arctanh(11^(1/2)*(-430102550046233+304411898150000*2^(1/2))^-1//2*(3+-1x+2*x^2)^-1//2*(5538393+-4123702*2^(1/2)+x*(13785797+-9662095*2^(1/2))))+-1//941410976*(3+-1x+2*x^2)^-1//2*(4353943+-6508666x)+3//81861824*(13874275807943//682+4909869325000//341*2^(1/2))^(1/2)*arctan(11^(1/2)*(430102550046233+304411898150000*2^(1/2))^-1//2*(3+-1x+2*x^2)^-1//2*(5538393+4123702*2^(1/2)+x*(13785797+9662095*2^(1/2))))+1//1364*(2+3x+5*x^2)^-2*(3+-1x+2*x^2)^-1//2*(4+65x)+1//1860496*(2+3x+5*x^2)^-1*(3+-1x+2*x^2)^-1//2*(36590+86575x))
@test integrate((2+3x+5*x^2)^4*(3+-1x+2*x^2)^-5//2, x) == :(-1308645//4096*(3+-1x+2*x^2)^(1/2)+-1//4416*(3+-1x+2*x^2)^-3//2*(1478741+1156639x)+1//101568*(3+-1x+2*x^2)^-1//2*(9861379+154885808x)+625//32*x^3*(3+-1x+2*x^2)^(1/2)+38375//384*x^2*(3+-1x+2*x^2)^(1/2)+526075//3072*x*(3+-1x+2*x^2)^(1/2)+16955197//16384*2^(1/2)*arcsinh(1//23*23^(1/2)*(1+-4x)))
@test integrate((2+3x+5*x^2)^3*(3+-1x+2*x^2)^-5//2, x) == :(3175//64*(3+-1x+2*x^2)^(1/2)+-7495//256*2^(1/2)*arcsinh(1//23*23^(1/2)*(1+-4x))+-1//1104*(3+-1x+2*x^2)^-3//2*(22627+-59895x)+1//8464*(3+-1x+2*x^2)^-1//2*(1292159+-816024x)+125//16*x*(3+-1x+2*x^2)^(1/2))
@test integrate((2+3x+5*x^2)^2*(3+-1x+2*x^2)^-5//2, x) == :(-25//8*2^(1/2)*arcsinh(1//23*23^(1/2)*(1+-4x))+-1//6348*(3+-1x+2*x^2)^-1//2*(80861+25696x)+1//276*(3+-1x+2*x^2)^-3//2*(2299+-847x))
@test integrate((3+-1x+2*x^2)^-5//2*(2+3x+5*x^2), x) == :(-1//529*(3+-1x+2*x^2)^-1//2*(71+-284x)+1//69*(3+-1x+2*x^2)^-3//2*(-55+-33x))
@test integrate((2+3x+5*x^2)^-1*(3+-1x+2*x^2)^-5//2, x) == :(-1//484*(15457//682+12500//341*2^(1/2))^(1/2)*arctanh(11^(1/2)*(479167+775000*2^(1/2))^-1//2*(3+-1x+2*x^2)^-1//2*(443+98*2^(1/2)+x*(247+-345*2^(1/2))))+1//484*(-15457//682+12500//341*2^(1/2))^(1/2)*arctan(11^(1/2)*(-479167+775000*2^(1/2))^-1//2*(3+-1x+2*x^2)^-1//2*(443+-98*2^(1/2)+x*(247+345*2^(1/2))))+1//759*(3+-1x+2*x^2)^-3//2*(13+-6x)+1//128018*(3+-1x+2*x^2)^-1//2*(3603+-658x))
@test integrate((2+3x+5*x^2)^-2*(3+-1x+2*x^2)^-5//2, x) == :(-625//660176*(-30463//682+11800//341*2^(1/2))^(1/2)*arctanh(11^(1/2)*(-944353+731600*2^(1/2))^-1//2*(3+-1x+2*x^2)^-1//2*(203+-242*2^(1/2)+x*(687+-445*2^(1/2))))+-1//1035276*(3+-1x+2*x^2)^-3//2*(15101+-8654x)+-1//523849656*(3+-1x+2*x^2)^-1//2*(3133427+1352542x)+625//660176*(30463//682+11800//341*2^(1/2))^(1/2)*arctan(11^(1/2)*(944353+731600*2^(1/2))^-1//2*(3+-1x+2*x^2)^-1//2*(203+242*2^(1/2)+x*(687+445*2^(1/2))))+1//682*(2+3x+5*x^2)^-1*(3+-1x+2*x^2)^-3//2*(4+65x))
@test integrate((2+3x+5*x^2)^-3*(3+-1x+2*x^2)^-5//2, x) == :(-35//1800960128*(-2243059557247//682+1005874250000//341*2^(1/2))^(1/2)*arctanh(11^(1/2)*(-69534846274657+62364203500000*2^(1/2))^-1//2*(3+-1x+2*x^2)^-1//2*(1432939+-2428746*2^(1/2)+x*(6290431+-3861685*2^(1/2))))+-1//2824232928*(3+-1x+2*x^2)^-3//2*(12280939+-19536786x)+-1//476353953856*(3+-1x+2*x^2)^-1//2*(1134826571+-1504660754x)+35//1800960128*(2243059557247//682+1005874250000//341*2^(1/2))^(1/2)*arctan(11^(1/2)*(69534846274657+62364203500000*2^(1/2))^-1//2*(3+-1x+2*x^2)^-1//2*(1432939+2428746*2^(1/2)+x*(6290431+3861685*2^(1/2))))+1//1364*(2+3x+5*x^2)^-2*(3+-1x+2*x^2)^-3//2*(4+65x)+1//1860496*(2+3x+5*x^2)^-1*(3+-1x+2*x^2)^-3//2*(46386+86885x))
@test integrate((a+b*x+c*x^2)^(1/2)*(d+e*x+f*x^2)^2, x) == :(1//960*c^-4*(a+b*x+c*x^2)^3//2*(-105*b^3*f^2+-8*c^2*(25*b*(e^2+2*d*f)+32*a*e*f)+640*d*e*c^3+28*b*c*f*(7*a*f+10*b*e))+-1//1024*c^-11//2*(b^2+-4*a*c)*(-32*c^3*(a*(e^2+2*d*f)+4*b*d*e)+8*c^2*(2*a^2*f^2+5*b^2*(e^2+2*d*f)+12*a*b*e*f)+21*b^4*f^2+128*c^4*d^2+-56*c*f*b^2*(a*f+b*e))*arctanh((1/2)*c^-1//2*(a+b*x+c*x^2)^-1//2*(b+2*c*x))+1//6*c^-1*f^2*x^3*(a+b*x+c*x^2)^3//2+1//160*x*c^-3*(a+b*x+c*x^2)^3//2*(21*b^2*f^2+40*c^2*(e^2+2*d*f)+-4*c*f*(5*a*f+14*b*e))+1//512*c^-5*(a+b*x+c*x^2)^(1/2)*(b+2*c*x)*(-32*c^3*(a*(e^2+2*d*f)+4*b*d*e)+8*c^2*(2*a^2*f^2+5*b^2*(e^2+2*d*f)+12*a*b*e*f)+21*b^4*f^2+128*c^4*d^2+-56*c*f*b^2*(a*f+b*e))+1//20*f*c^-2*x^2*(a+b*x+c*x^2)^3//2*(-3*b*f+8*c*e))
@test integrate((a+b*x+c*x^2)^(1/2)*(d+e*x+f*x^2), x) == :(1//24*c^-2*(a+b*x+c*x^2)^3//2*(-5*b*f+8*c*e)+-1//128*c^-7//2*(b^2+-4*a*c)*(-4*c*(a*f+2*b*e)+5*f*b^2+16*d*c^2)*arctanh((1/2)*c^-1//2*(a+b*x+c*x^2)^-1//2*(b+2*c*x))+1//4*f*x*c^-1*(a+b*x+c*x^2)^3//2+1//64*c^-3*(a+b*x+c*x^2)^(1/2)*(b+2*c*x)*(5*f*b^2+16*d*c^2+-8*b*c*e+-4*a*c*f))
@test integrate((a+b*x+c*x^2)^(1/2)*(d+e*x+f*x^2)^-1, x) == :(c^(1/2)*f^-1*arctanh((1/2)*c^-1//2*(a+b*x+c*x^2)^-1//2*(b+2*c*x))+(1/2)*2^(1/2)*f^-1*(e^2+-4*d*f)^-1//2*(c*(e^2+e*(e^2+-4*d*f)^(1/2)+-2*d*f)+f*(-1*b*(e+(e^2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x^2)^-1//2*(b+2*c*x))+1//7680*c^-6*(a+b*x+c*x^2)^(1/2)*(-3465*b^5*f^3+-640*c^4*(8*a*e*(e^2+6*d*f)+27*b*d*(e^2+d*f))+96*c^3*(50*b^2*(e^3+6*d*e*f)+128*e*a^2*f^2+275*a*b*f*(e^2+d*f))+23040*e*c^5*d^2+-504*b*f*c^2*(22*a^2*f^2+25*b^2*(e^2+d*f)+70*a*b*e*f)+420*c*b^3*f^2*(27*b*e+34*a*f))+-1//960*c^-4*x^2*(a+b*x+c*x^2)^(1/2)*(-320*c^3*(e^3+6*d*e*f)+231*b^3*f^3+24*f*c^2*(35*b*(e^2+d*f)+32*a*e*f)+-36*b*c*f^2*(13*a*f+21*b*e))+1//6*c^-1*f^3*x^5*(a+b*x+c*x^2)^(1/2)+1//3840*x*c^-5*(a+b*x+c*x^2)^(1/2)*(-160*c^3*(10*b*(e^3+6*d*e*f)+27*a*f*(e^2+d*f))+1155*b^4*f^3+24*f*c^2*(50*a^2*f^2+175*b^2*(e^2+d*f)+322*a*b*e*f)+5760*d*c^4*(e^2+d*f)+-252*c*b^2*f^2*(14*a*f+15*b*e))+1//60*c^-2*f^2*x^4*(a+b*x+c*x^2)^(1/2)*(-11*b*f+36*c*e)+1//480*f*c^-3*x^3*(a+b*x+c*x^2)^(1/2)*(99*b^2*f^2+360*c^2*(e^2+d*f)+-4*c*f*(25*a*f+81*b*e)))
@test integrate((a+b*x+c*x^2)^-1//2*(d+e*x+f*x^2)^2, x) == :(1//128*c^-9//2*(-64*c^3*(a*(e^2+2*d*f)+2*b*d*e)+35*b^4*f^2+48*c^2*(a^2*f^2+b^2*(e^2+2*d*f)+4*a*b*e*f)+128*c^4*d^2+-40*c*f*b^2*(2*b*e+3*a*f))*arctanh((1/2)*c^-1//2*(a+b*x+c*x^2)^-1//2*(b+2*c*x))+1//192*c^-4*(a+b*x+c*x^2)^(1/2)*(-105*b^3*f^2+-16*c^2*(9*b*(e^2+2*d*f)+16*a*e*f)+384*d*e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-1*a*e)+d*b^2+-1*a*(e*(b^2+-4*a*c)^(1/2)+-2*a*f+2*c*d))^-1//4*(f*b^2+-1*(b^2+-4*a*c)^(1/2)*(c*e+-1*b*f)+2*d*c^2+-1*b*c*e+-2*a*c*f)^1//4),1/2+1//4*(b*(d*(b^2+-4*a*c)^(1/2)+-1*a*e)+d*b^2+-1*a*(e*(b^2+-4*a*c)^(1/2)+-2*a*f+2*c*d))^-1//2*(-1*c*(b*e+e*(b^2+-4*a*c)^(1/2)+2*a*f)+2*d*c^2+b*f*(b+(b^2+-4*a*c)^(1/2)))^-1//2*(b+(b^2+-4*a*c)^(1/2))*(-1*b*e+2*a*f+2*c*d)))

max_stars_repo_path: test/1 Algebraic functions/1.2 Trinomial products/1.2.1 Quadratic/1.2.1.5 (a+b x+c x^2)^p (d+e x+f x^2)^q.jl


text:
# using Revise
using HardSphereDynamics
using StaticArrays
using LinearAlgebra

box = HardSphereDynamics.unit_hypercube(2, Float64)

balls = [MovableBall(SVector(0.0, 0.0), SVector(0.0, 0.0), 0.2, Inf),
        MovableBall(SVector(0.3, 0.0), normalize(SVector(1.0, sqrt(2))), 0.1)]

fluid = HardSphereFluid(box, balls)

δt = 0.01
final_time = 100
positions, velocities, times = evolve!(fluid, δt, final_time)  # return data at given times

# using Plots

using Makie

visualize_2d(fluid, positions, velocities)

max_stars_repo_name: dpsanders/HardSphereDynamics

max_forks_repo_name: dpsanders/HardSphereDynamics


text:
# Copyright 2020 Digital Domain 3.0
#
# Licensed under the Apache License, Version 2.0 (the "Apache License")
# with the following modification; you may not use this file except in
# compliance with the Apache License and the following modification to it:
# Section 6. Trademarks. is deleted and replaced with:
#
# 6. Trademarks. This License does not grant permission to use the trade
#    names, trademarks, service marks, or product names of the Licensor
#    and its affiliates, except as required to comply with Section 4(c) of
#    the License and to reproduce the content of the NOTICE file.
#
# You may obtain a copy of the Apache License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the Apache License with the above modification is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the Apache License for the specific
# language governing permissions and limitations under the Apache License.

using Test
using Blades
using KVectors
using KForms
using LinearAlgebra

module G2
  using Blades
  # need last param to be true for differential forms
  @generate_basis("++",false,true,true)
end

module G3
  using Blades
  @generate_basis("+++",false,true,true)
end

using .G2
using .G3

zerofun(x,y...) = zero(x)

@testset "CMU DEC course G2" begin
  e₁, e₂, e₁₂ = alle( G2, 2)
  e¹, e², e¹² = alld( G2, 2)
  𝐼 = 1e₁₂

  # http://brickisland.net/DDGSpring2019/wp-content/uploads/2019/01/DDG_458_SP19_Lecture04_kForms.pdf
  # 1-form example in coordinates
  v = 2e₁ + 2e₂
  α = -2e¹ + 3e²
  # could repeat this test in multivectors when * is defined, here we use ⋅ instead of *
  @test α⋅v == 2 == α⋅reverse(v) # == apply(α,v)

  # 2-form example in coordinates
  u = 2e₁ + 2e₂; v = -2e₁ + 2e₂
  α = 1e¹ + 3e²; β = 2e¹ + 1e²
  @test (α∧β)*reverse(u∧v) == -40 == kform(α∧β,u∧v)

  # lecture 6 slides: α(x,y)=xdx + ydy
  ∂αᵢ∂e = [1 0; 0 1]
  α = 1e₁+1e₂ # evaluate anywhere, so choose 1,1
  @test 𝑑(α, ∂αᵢ∂e) == 0
  # negative x row is in dual basis
  star_∂αᵢ∂e = [0 1; 1 0]
  @test 𝑑(⋆α, star_∂αᵢ∂e) == 2e₁₂

  # use ZForm type
  α = e₁(ZForm{2}((x,y)->x, [(x,y)->1, (x,y)->0])) +
      e₂(ZForm{2}((x,y)->y, [(x,y)->0, (x,y)->1]))
  @test apply(α, KVector(2e₂), 1e₁+1e₂) == 2
  @test apply(α, KVector(3e₂+2e₂), 1e₁+1e₂) == 5
  @test apply(𝑑(α), 1e₁+1e₂, KVector(1e₁₂)) == 0
  @test apply(𝑑(⋆α), 1e₁+1e₂, KVector(1e₁₂)) == 2.0
  @test apply(𝑑(⋆⋆α), 1e₁+1e₂, KVector(1e₁₂)) == 0
  @test apply(𝑑(⋆⋆⋆α), 1e₁+1e₂, KVector(1e₁₂)) == -2.0

  # a naked zero form: ϕ(x,y) = ½e⁻⁽ˣ²⁺ʸ²)
  # dϕ = -2*ϕ*(xdx + ydy)
  # expected result: -2*ϕ*x*e₁ + -2*ϕ*y*e₁
  # -2*ϕ(0.2,0.3)*0.2*e₁ + -2*ϕ*(0.2,0.3)*0.3*e₂
  xy = 0.2e₁+0.3e₂

  ϕ(x,y) = 0.5*exp(-(x^2+y^2))

  # evaluate at 0.2,0.3
  α = ZForm{2}(ϕ, [(x,y)->-2.0*ϕ(x,y)*x,
                (x,y)->-2.0*ϕ(x,y)*y])
  dp = 𝑑(α, 𝐼)
  dp = sortbasis(dp)
  @test untype(dp[1]) == e₁
  @test untype(dp[2]) == e₂
  @test dp[1].x.f(0.2,0.3) == -2.0*ϕ(coords(xy)...)*xy[1].x
  @test dp[2].x.f(0.2,0.3) == -2.0*ϕ(coords(xy)...)*xy[2].x
  @test apply(dp, xy, 1.0e₁+1.0e₂) ==  -2.0*ϕ(coords(xy)...)*xy[1].x + -2.0*ϕ(coords(xy)...)*xy[2].x

  # http://brickisland.net/DDGSpring2019/wp-content/uploads/2019/02/DDG_458_SP19_Lecture07_ExteriorIntegration.pdf
  # Integration of differential 2-forms: - Example

  ϕ(x,y) = x + x*y
  ω = ZForm{2}(ϕ, [(x,y)->1.0+y, (x,y)->x])∧e₁₂
  dx = 0.005; dy= 0.005;  dA = (dx*dy)e₁₂; Ω = [(xᵢ,yᵢ) for xᵢ in 0:dx:1.0 for yᵢ in 0.0:dy:1.0];
  integ_ω = mapreduce(xy->apply(ω, xy[1]*e₁ + xy[2]*e₂, KVector(dA)),+,Ω)
  # as dA -> 0 ∑ω(p)dA = ∫ωdA = 0.75
  @test abs(integ_ω - 3/4) < 0.01;

  # inner product of 1-forms - Example
  α = ZForm{2}((x,y)->1.0, [(x,y)->0.0, (x,y)->0.0])∧e₁
  βₓ = ZForm{2}((x,y)->x, [(x,y)->1.0, (x,y)->0.0])∧e₁
  βᵥ = ZForm{2}((x,y)->-y, [(x,y)->0.0, (x,y)->-1.0])∧e₂
  ω = ⋆(α)∧(βₓ+βᵥ)
  integ_ω = mapreduce(xy->apply(ω, xy[1]*e₁ + xy[2]*e₂, KVector(dA)),+,Ω)
  @test abs(integ_ω - (-1/2)) < 0.01;

  # http://brickisland.net/DDGSpring2019/wp-content/uploads/2019/02/ExteriorCalculus-1.pdf
  # Exercize 13
  ϕ(x,y) = x*y+2*(y^2)
  α = ZForm{2}(ϕ, [(x,y)->y, (x,y)->x + 4y], [(x,y)->0 (x,y)->1 ; (x,y)->1 (x,y)->4])
  @test apply(KForms.Δ(α), 1e₁+1e₂) == 4

  # http://brickisland.net/DDGSpring2019/wp-content/uploads/2019/02/DDG_458_SP19_Lecture08_DiscreteDifferentialForms-1.pdf
  # Integrating a 1-Form over and Edge - Example
  α = ZForm{2}((x,y)->x*y, [(x,y)->y, (x,y)->x])∧e₁ + ZForm{2}((x,y)->-x*x, [(x,y)->-2.0x, zerofun])∧e₂

  p₁ = -1.0e₁ + 2.0e₂
  p₂ = 3.0e₁ + 1.0e₂
  L = sqrt(17.0)
  T = (p₂-p₁)/L
  p(s) = p₁ + (s/L)*(p₂-p₁)
  ds = 0.01
  p0L = map(s->p(s),0:ds:L);
  αT = apply(α, T)
  @test round(mapreduce(pᵢ->apply(αT, pᵢ),+,p0L)*ds) == 7.0

  # Exterior Derivative on Vector-Valued Forms
  # http://brickisland.net/DDGSpring2019/wp-content/uploads/2019/02/DDG_458_SP19_Lecture10_SmoothCurves.pdf
  ϕ = ZForm{2}((x,y)->[x^2,x*y], [(x,y)->[2x,y], (x,y)->[0.0,x]])∧e₁ +
      ZForm{2}((x,y)->[x*y,y^2], [(x,y)->[y,0.0], (x,y)->[x,2y]])∧e₂

  @test apply(𝑑(ϕ), 3.0e₁+5.0e₂, 1.0e₁₂) == [5.0, -3.0]

end

@testset "CMU DEC course G3" begin

  e₁, e₂, e₃, e₁₂, e₁₃, e₂₃, e₁₂₃ = alle( G3, 3)

  @test (1.0e₂∧1.0e₃)∧⋆(1.0e₂∧1.0e₃) == 1.0e₁₂₃
  @test (1.0e₂)∧⋆(1.0e₂) == 1.0e₁₂₃
  @test (-2.0e₂)∧⋆(-2.0e₂) == 4.0e₁₂₃

  u = 2.0e₁ + 2.0e₂; v = -2.0e₁ + 2.0e₂
  detuv = det(hcat(vcat(magnitude.(u),0.0), vcat(magnitude.(v),0.0), [0.0,0.0,magnitude.(⋆(u∧v))]))
  @test detuv > 0
  #two orthonormal vectors u1, u2, we ask that det(u1, u2, ⋆(u1 ∧ u2)) = 1
  u = normalize(u); v = normalize(v)
  detuv = det(hcat(vcat(magnitude.(u),0.0), vcat(magnitude.(v),0.0), [0.0,0.0,magnitude.(⋆(u∧v))]))
  @test detuv ≈ 1

  u = -2.0e₂; v = 1.0e₃; uv = u∧v
  detuv = det(hcat([0.0,magnitude.(u),0.0], [0.0,0.0,magnitude.(v)], [magnitude.(⋆(uv)),0,0]))
  @test detuv > 0

  @test ⋆(-1.0e₁∧1.0e₂ - 1.0e₁∧1.0e₃ - 2.0e₂∧1.0e₃) == -2.0e₁ + 1.0e₂ - 1.0e₃

end

@testset "differential forms" begin
  e₁, e₂, e₁₂ = alle( G2, 2)
  𝐼 = 1e₁₂

  α = ZForm{2}((x,y)->x^3, [(x,y)->3.0*x^2, (x,y)->0.0],[(x,y)->6.0x (x,y)->0.0 ; (x,y)->0.0 (x,y)->0.0])
  @test apply(𝑑(𝑑(α, 𝐼)), 1.0e₁+1.0e₂, 1.0e₁₂) == 0.0

  α = ZForm{2}((x,y)->y*x^3 + x*y^2,
               [(x,y)->y*3.0x^2 + y^2,
                (x,y)->x^3 +      x*2.0y],
               [(x,y)->y*6.0x     (x,y)->3.0x^2 + 2.0y ;
                (x,y)->3.0x^2 + 2.0y  (x,y)->2.0])

  @test apply(𝑑(𝑑(α, 𝐼)), 1.0e₁+1.5e₂, 1.0e₁₂) == 0.0
  @test apply(𝑑(⋆𝑑(α, 𝐼)), 1.0e₁+1.5e₂, 1.0e₁₂) != 0.0
end


text:
# Here I include some maps between the experimental
# data ids and the model ids

## -------------------------------------------------------------------
# maps between Heerden2013 https://doi.org/10.1186/1475-2859-12-80
# data and the model

# Mets map
const Hd_mets_map = Dict();
function _set_Hd_mets_map()
    empty!(Hd_mets_map)
    Hd_mets_map["GLC"] = "glc__D_e";
    Hd_mets_map["SUCC"] = "succ_e";
    Hd_mets_map["AC"] = "ac_e";
    Hd_mets_map["FORM"] = "for_e";
    Hd_mets_map["MAL"] = "mal__L_e";
    for (k, v) in Hd_mets_map
        Hd_mets_map[v] = k
    end
    Hd_mets_map
end

# base model exch met map
# A quick way to get exchages from mets and te other way around
const exch_met_map = Dict()
function _load_exch_met_map()
    !isfile(EXCH_MET_MAP_FILE) && return exch_met_map
    empty!(exch_met_map)
    merge!(exch_met_map, load_data(EXCH_MET_MAP_FILE; verbose = false))
    return exch_met_map
end


text:
function loadData_vKITTI(worlds,variations,model,mode)
    colors = 0; x = 0;
    y = zeros(Float32,224,224,13,1)
    if model in ("RGB_VGG",)
        #RGB
        x = zeros(Float32,224,224,3,1)
        for world in worlds
            for variation in variations
                worldfile = load(joinpath(dataDIR,"vKITTI","world_$(world)_$(variation).jld"))
                if mode == "odd"
                    x = cat(4,x,worldfile["RGB"][:,:,:,1:2:end])
                    y = cat(4,y,worldfile["GT"][:,:,:,1:2:end])
                elseif mode == "even"
                    x = cat(4,x,worldfile["RGB"][:,:,:,2:2:end])
                    y = cat(4,y,worldfile["GT"][:,:,:,2:2:end])
                elseif mode == "firstHalf"
                    x = cat(4,x,worldfile["RGB"][:,:,:,1:div(end,2)])
                    y = cat(4,y,worldfile["GT"][:,:,:,1:div(end,2)])
                elseif mode == "secondHalf"
                    x = cat(4,x,worldfile["RGB"][:,:,:,div(end,2)+1:end])
                    y = cat(4,y,worldfile["GT"][:,:,:,div(end,2)+1:end])
                elseif mode == "full"
                    x = cat(4,x,worldfile["RGB"][:,:,:,:])
                    y = cat(4,y,worldfile["GT"][:,:,:,:])
                end
                colors = worldfile["colors"]
            end
        end
        x = x[:,:,:,2:end]
        y = y[:,:,:,2:end]
    elseif model in ("RGBD_VGG",)
        #RGB + Colorized depth
        x = zeros(Float32,224,224,3,1)
        d = zeros(Float32,224,224,3,1)
        for world in worlds
            for variation in variations
                worldfile = load(joinpath(dataDIR,"vKITTI","world_$(world)_$(variation).jld"))
                if mode == "odd"
                    x = cat(4,x,worldfile["RGB"][:,:,:,1:2:end])
                    d = cat(4,d,worldfile["DepthRGB"][:,:,:,1:2:end])
                    y = cat(4,y,worldfile["GT"][:,:,:,1:2:end])
                elseif mode == "even"
                    x = cat(4,x,worldfile["RGB"][:,:,:,2:2:end])
                    d = cat(4,d,worldfile["DepthRGB"][:,:,:,2:2:end])
                    y = cat(4,y,worldfile["GT"][:,:,:,2:2:end])
                elseif mode == "firstHalf"
                    x = cat(4,x,worldfile["RGB"][:,:,:,1:div(end,2)])
                    d = cat(4,d,worldfile["DepthRGB"][:,:,:,1:div(end,2)])
                    y = cat(4,y,worldfile["GT"][:,:,:,1:div(end,2)])
                elseif mode == "secondHalf"
                    x = cat(4,x,worldfile["RGB"][:,:,:,div(end,2)+1:end])
                    d = cat(4,d,worldfile["DepthRGB"][:,:,:,div(end,2)+1:end])
                    y = cat(4,y,worldfile["GT"][:,:,:,div(end,2)+1:end])
                elseif mode == "full"
                    x = cat(4,x,worldfile["RGB"][:,:,:,:])
                    d = cat(4,d,worldfile["DepthRGB"][:,:,:,:])
                    y = cat(4,y,worldfile["GT"][:,:,:,:])
                end
                colors = worldfile["colors"]
            end
        end
        x = x[:,:,:,2:end]
        d = d[:,:,:,2:end]
        y = y[:,:,:,2:end]
        x = cat(3,x,d)
    elseif model in ("D_VGG",)
        #Colorized depth
        x = zeros(Float32,224,224,3,1)
        for world in worlds
            for variation in variations
                worldfile = load(joinpath(dataDIR,"vKITTI","world_$(world)_$(variation).jld"))
                if mode == "odd"
                    x = cat(4,x,worldfile["DepthRGB"][:,:,:,1:2:end])
                    y = cat(4,y,worldfile["GT"][:,:,:,1:2:end])
                elseif mode == "even"
                    x = cat(4,x,worldfile["DepthRGB"][:,:,:,2:2:end])
                    y = cat(4,y,worldfile["GT"][:,:,:,2:2:end])
                elseif mode == "firstHalf"
                    x = cat(4,x,worldfile["DepthRGB"][:,:,:,1:div(end,2)])
                    y = cat(4,y,worldfile["GT"][:,:,:,1:div(end,2)])
                elseif mode == "secondHalf"
                    x = cat(4,x,worldfile["DepthRGB"][:,:,:,div(end,2)+1:end])
                    y = cat(4,y,worldfile["GT"][:,:,:,div(end,2)+1:end])
                elseif mode == "full"
                    x = cat(4,x,worldfile["DepthRGB"][:,:,:,:])
                    y = cat(4,y,worldfile["GT"][:,:,:,:])
                end
                colors = worldfile["colors"]
            end
        end
        x = x[:,:,:,2:end]
        y = y[:,:,:,2:end]
    end
    return x,y,colors
end

function loadData_DAVIS()
    videoDIR = joinpath(dataDIR,"DAVIS")
    #Train
    xtrain = zeros(Float32,224,224,3,1)
    ytrain = zeros(Float32,224,224,2,1)
    #Test
    xtest = zeros(Float32,224,224,3,1)
    ytest = zeros(Float32,224,224,2,1)
    for video in readdir(videoDIR)
        datafile = load(joinpath(videoDIR,video))

        xtrain = cat(4,xtrain,datafile["x"][:,:,:,1:div(end,2)])
        ytrain = cat(4,ytrain,datafile["y"][:,:,:,1:div(end,2)])

        xtest = cat(4,xtest,datafile["x"][:,:,:,div(end,2)+1:end])
        ytest = cat(4,ytest,datafile["y"][:,:,:,div(end,2)+1:end])
    end
    xtrain = xtrain[:,:,:,2:end]
    ytrain = ytrain[:,:,:,2:end]

    xtest = xtest[:,:,:,2:end]
    ytest = ytest[:,:,:,2:end]

    return xtrain,ytrain,xtest,ytest
end

function loadData_Robot(model,mode)
    ddir = joinpath(dataDIR,"Robot")
    rooms = filter!(r".jld", readdir(ddir))

    x = 0;
    y = zeros(Float32,224,224,5,1)
    if model in ("RGB",)
        #RGB
        x = zeros(Float32,224,224,3,1)
        for room in rooms
            roomfile = load(joinpath(ddir,room))
            seqparts = []
            seqn = size(roomfile["GT"],4)
            if seqn % 4 == 0
                sz = Int(floor(seqn/4))
                for i=1:4
                    push!(seqparts,(i-1)*sz+1:i*sz)
                end
            else
                sz = Int(floor(seqn/4))
                for i=1:4
                    if i!=4
                        push!(seqparts,(i-1)*sz+1:i*sz)
                    else
                        push!(seqparts,(i-1)*sz+1:seqn)
                    end
                end
            end
            if mode == "train"
                x = cat(4,x,roomfile["RGB"][:,:,:,seqparts[1]])
                y = cat(4,y,roomfile["GT"][:,:,:,seqparts[1]])
                x = cat(4,x,roomfile["RGB"][:,:,:,seqparts[2]])
                y = cat(4,y,roomfile["GT"][:,:,:,seqparts[2]])
                x = cat(4,x,roomfile["RGB"][:,:,:,seqparts[4]])
                y = cat(4,y,roomfile["GT"][:,:,:,seqparts[4]])
            elseif mode == "test"
                x = cat(4,x,roomfile["RGB"][:,:,:,seqparts[3]])
                y = cat(4,y,roomfile["GT"][:,:,:,seqparts[3]])
            end
        end
        x = x[:,:,:,2:end]
        y = y[:,:,:,2:end]
    elseif model in ("RGBD",)
        #RGB + Colorized depth
        x = zeros(Float32,224,224,3,1)
        d = zeros(Float32,224,224,3,1)
        for room in rooms
            roomfile = load(joinpath(ddir,room))
            seqparts = []
            seqn = size(roomfile["GT"],4)
            if seqn % 4 == 0
                sz = Int(floor(seqn/4))
                for i=1:4
                    push!(seqparts,(i-1)*sz+1:i*sz)
                end
            else
                sz = Int(floor(seqn/4))
                for i=1:4
                    if i!=4
                        push!(seqparts,(i-1)*sz+1:i*sz)
                    else
                        push!(seqparts,(i-1)*sz+1:seqn)
                    end
                end
            end
            if mode == "train"
                x = cat(4,x,roomfile["RGB"][:,:,:,seqparts[1]])
                d = cat(4,d,roomfile["DepthRGB"][:,:,:,seqparts[1]])
                y = cat(4,y,roomfile["GT"][:,:,:,seqparts[1]])
                x = cat(4,x,roomfile["RGB"][:,:,:,seqparts[2]])
                d = cat(4,d,roomfile["DepthRGB"][:,:,:,seqparts[2]])
                y = cat(4,y,roomfile["GT"][:,:,:,seqparts[2]])
                x = cat(4,x,roomfile["RGB"][:,:,:,seqparts[4]])
                d = cat(4,d,roomfile["DepthRGB"][:,:,:,seqparts[4]])
                y = cat(4,y,roomfile["GT"][:,:,:,seqparts[4]])
            elseif mode == "test"
                x = cat(4,x,roomfile["RGB"][:,:,:,seqparts[3]])
                d = cat(4,d,roomfile["DepthRGB"][:,:,:,seqparts[3]])
                y = cat(4,y,roomfile["GT"][:,:,:,seqparts[3]])
            end
        end
        x = x[:,:,:,2:end]
        d = d[:,:,:,2:end]
        y = y[:,:,:,2:end]
        x = cat(3,x,d)
    elseif model in ("D",)
        #Colorized depth
        x = zeros(Float32,224,224,3,1)
        for room in rooms
            roomfile = load(joinpath(ddir,room))
            seqparts = []
            seqn = size(roomfile["GT"],4)
            if seqn % 4 == 0
                sz = Int(floor(seqn/4))
                for i=1:4
                    push!(seqparts,(i-1)*sz+1:i*sz)
                end
            else
                sz = Int(floor(seqn/4))
                for i=1:4
                    if i!=4
                        push!(seqparts,(i-1)*sz+1:i*sz)
                    else
                        push!(seqparts,(i-1)*sz+1:seqn)
                    end
                end
            end
            if mode == "train"
                x = cat(4,x,roomfile["DepthRGB"][:,:,:,seqparts[1]])
                y = cat(4,y,roomfile["GT"][:,:,:,seqparts[1]])
                x = cat(4,x,roomfile["DepthRGB"][:,:,:,seqparts[2]])
                y = cat(4,y,roomfile["GT"][:,:,:,seqparts[2]])
                x = cat(4,x,roomfile["DepthRGB"][:,:,:,seqparts[4]])
                y = cat(4,y,roomfile["GT"][:,:,:,seqparts[4]])
            elseif mode == "test"
                x = cat(4,x,roomfile["DepthRGB"][:,:,:,seqparts[3]])
                y = cat(4,y,roomfile["GT"][:,:,:,seqparts[3]])
            end
        end
        x = x[:,:,:,2:end]
        y = y[:,:,:,2:end]
    end
    return x,y
end

function savePrediction(ypred,colors,filename)
    im = zeros(Float32,size(ypred,1),size(ypred,2),3)
    for wi=1:size(ypred,1)
        for hi=1:size(ypred,2)
            im[wi,hi,:] = colors[indmax(ypred[wi,hi,:])]
        end
    end
    im = convert(Image{RGB},im)
    im["spatialorder"] = ["x","y"]

    t = splitdir(filename)
    if !isdir(t[1])
        mkpath(t[1])
    end

    Images.save(filename,im)
end

max_stars_repo_name: eeyrdkl/MScThesis

max_issues_repo_name: eeyrdkl/MScThesis

max_forks_repo_name: eeyrdkl/MScThesis