Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions include/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
#include <petsc.h>
#define freq 60.0 /**< System frequency */
#define w_s (2.0 * PETSC_PI * freq) /**< Angular speed */
#define MAXLINE 10000 /**< Max. number of characters in a line */
#define ISOLATED_BUS 4 /**< Isolated bus */
#define REF_BUS 3 /**< Reference bus (swing bus) */
#define PV_BUS 2 /**< PV (voltage-controlled) bus */
#define PQ_BUS 1 /**< PQ bus */
// FIXME: either validate that a line fits within this buffer or replace the use
// of a fixed-size buffer
#define MAXLINE 1000000 /**< Max. number of characters in a line */
#define ISOLATED_BUS 4 /**< Isolated bus */
#define REF_BUS 3 /**< Reference bus (swing bus) */
#define PV_BUS 2 /**< PV (voltage-controlled) bus */
#define PQ_BUS 1 /**< PQ bus */
#define NGEN_AT_BUS_MAX \
32 /**< Maximum number of generators allowed at a bus \
*/
Expand Down
12 changes: 6 additions & 6 deletions src/tcopflow/interface/tcopflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,9 +527,9 @@ PetscErrorCode TCOPFLOWSetUp(TCOPFLOW tcopflow) {
CHKERRQ(ierr);
ierr = MatSetFromOptions(tcopflow->Jac);
CHKERRQ(ierr);
/* Assume 10% sparsity */
ierr = MatSeqAIJSetPreallocation(tcopflow->Jac,
(PetscInt)(0.1 * tcopflow->Nx), NULL);
/* Assume 10% sparsity with a minimum of 50 nz per row */
PetscInt jac_nz_per_row = PetscMin((PetscInt)(0.1 * tcopflow->Nx), 50);
ierr = MatSeqAIJSetPreallocation(tcopflow->Jac, jac_nz_per_row, NULL);
CHKERRQ(ierr);
ierr =
MatSetOption(tcopflow->Jac, MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE);
Expand All @@ -543,9 +543,9 @@ PetscErrorCode TCOPFLOWSetUp(TCOPFLOW tcopflow) {
CHKERRQ(ierr);
ierr = MatSetFromOptions(tcopflow->Hes);
CHKERRQ(ierr);
/* Assume 10% sparsity */
ierr = MatSeqAIJSetPreallocation(tcopflow->Hes,
(PetscInt)(0.1 * tcopflow->Nx), NULL);
/* Assume 10% sparsity with a minimum of 50 nz per row */
PetscInt hes_nz_per_row = PetscMin((PetscInt)(0.1 * tcopflow->Nx), 50);
ierr = MatSeqAIJSetPreallocation(tcopflow->Hes, hes_nz_per_row, NULL);
CHKERRQ(ierr);
ierr =
MatSetOption(tcopflow->Hes, MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE);
Expand Down
Loading