-- Table: public.bus_model

-- DROP
DROP TABLE IF EXISTS public.bus_model;
DROP SEQUENCE IF EXISTS public.bus_model_id_seq;

-- CREATE
CREATE SEQUENCE IF NOT EXISTS public.bus_model_id_seq;

CREATE TABLE IF NOT EXISTS public.bus_model
(
    id integer NOT NULL DEFAULT nextval('bus_model_id_seq'::regclass),
    component_id INTEGER NOT NULL DEFAULT -1,

    version INTEGER NOT NULL DEFAULT 0,

    init_voltage_rate DOUBLE PRECISION NOT NULL DEFAULT 100, -- 1~200
    init_voltage DOUBLE PRECISION NOT NULL DEFAULT 35, -- 0.01~1000
    init_voltage_phase DOUBLE PRECISION NOT NULL DEFAULT 0, -- -180~180
    rated_current DOUBLE PRECISION NOT NULL DEFAULT 1000, -- 0.01~65536
    dynamic_current DOUBLE PRECISION NOT NULL DEFAULT 40, -- 0.01~65536
    load_adjust_rate_min SMALLINT NOT NULL DEFAULT 100, -- 0~100
    load_adjust_rate_max SMALLINT NOT NULL DEFAULT 100, -- 0~100
    bus_type VARCHAR(32) NOT NULL DEFAULT 'PQ', -- 1 平衡母线/PV母线/PQ母线
    sc_capacity_s3max DOUBLE PRECISION NOT NULL DEFAULT 0, -- 0~65536
    sc_capacity_s3min DOUBLE PRECISION NOT NULL DEFAULT 0, -- 0~65536
    sc_capacity_i3max DOUBLE PRECISION NOT NULL DEFAULT 0, -- 0~65536
    sc_capacity_i3min DOUBLE PRECISION NOT NULL DEFAULT 0, -- 0~65536
    sc_capacity_z3max DOUBLE PRECISION NOT NULL DEFAULT 0.05, -- 0~100
    sc_capacity_z3min DOUBLE PRECISION NOT NULL DEFAULT 0.1, -- 0~100
    sc_capacity_s1max DOUBLE PRECISION NOT NULL DEFAULT 0, -- 0~65536
    sc_capacity_s1min DOUBLE PRECISION NOT NULL DEFAULT 0, -- 0~65536
    sc_capacity_i1max DOUBLE PRECISION NOT NULL DEFAULT 0, -- 0~65536
    sc_capacity_i1min DOUBLE PRECISION NOT NULL DEFAULT 0, -- 0~65536
    sc_capacity_z1max DOUBLE PRECISION NOT NULL DEFAULT 0.05, -- 0~100
    sc_capacity_z1min DOUBLE PRECISION NOT NULL DEFAULT 0.1, -- 0~100
    benchmark_voltage DOUBLE PRECISION NOT NULL DEFAULT 37, -- 0.01~500
    benchmark_capacity DOUBLE PRECISION NOT NULL DEFAULT 100, -- 0~65536

    op integer NOT NULL DEFAULT '-1'::integer,
    ts timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,

    CONSTRAINT bus_model_id_PrimaryKey PRIMARY KEY (id),
    CONSTRAINT bus_model_ForeignKey_component_id FOREIGN KEY (component_id)
        REFERENCES public.component (id) MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
)

TABLESPACE pg_default;

ALTER TABLE IF EXISTS public.bus_model
    OWNER to postgres;

COMMENT ON TABLE public.bus_model
    IS '存储母线的模型参数';