//main int main(int argc, char **argv){ int i, j, n, pv=0; char* file_name; cs *jac; N_Vector u; Gen *gens; double *u0; //load ps file, populate ps, and grab some data if(argc > 1) file_name = argv[1]; else{ printf("Please specify PS data file."); return 1; } PS ps=GetPS(file_name); if(ps==NULL){ printf("Unable to build PS data.\n"); return 1; } n=(ps->num_buses-1)<<1; gens=ps->gens; u=N_VNew_Serial(n); u0=NV_DATA_S(u); //create an initial condition if(gens[pv].index==ps->swing_bus)pv++; for(i=0;i<ps->ybus->n;i++){ if(i==ps->swing_bus) continue; j=(i>ps->swing_bus?(i-1)<<1:i<<1); if(gens[pv].index==i){ u0[j]=0.1; u0[j+1]=0.1; pv++; if(pv<ps->num_gens&&gens[pv].index==ps->swing_bus)pv++; continue; } u0[j]=1.0; u0[j+1]=0.1; } //numerically evaluate the jacobian at initial condition jac=CheckDerivativeN(n, n, ComputeF, u, (void*)ps); cs_di_print(jac, 0); //free memory and return N_VDestroy_Serial(u); return 0; }
int main(int argc, char **argv){ char* file_name; PS ps; double *xy0; printf("Launching Cosmic...\n"); //initialize MPI if we are using parallel code. #ifdef HAVE_MPI MPI_Init(&argc, &argv); #endif /* get the ps file from the terminal. assume the first argument is always the ps file. */ if(argc>1) file_name=argv[1]; else{ printf("Please specify PS data file."); return 1; } //get PS data from the file ps=GetPS(file_name); //check whether we were able to open the file if(ps==NULL){ printf("Unable to build PS data.\n"); return 1; } xy0=malloc(sizeof(int)); //call the initial condition solver. SolveIC(ps, xy0); //free initial condition memory free(xy0); //terminate MPI #ifdef HAVE_MPI MPI_Finalize(); #endif //free power system data and return FreePS(&ps); return 0; }
int FRAME_Window::proc( PQMSG pqmsg) { debug(3, 1)(__FUNCTION__"call with message %x\n",pqmsg->msg); switch(pqmsg->msg) { case WM_PAINT: HPS hps; hps = GetPS(); //draw frame Draw(hps); ReleasePS(hps); break; } //todo return NULL; }
int DeskTopWindow::proc( PQMSG pqmsg) { //todo switch(pqmsg->msg) { case WM_PAINT: debug(8, 0) ("DeskTopWindow::proc WM_PAINT\n"); /* the conclusion of the window of desktop */ { HPS hps; hps = GetPS(); Draw(hps); /* the conclusion of all daughterly windows of desktop */ } break; } return NULL; }
void vtVegLayer::AddElementsFromLULC(vtLULCFile *pLULC) { LULCSection *section; LULCPoly *poly; SetVegType(VLT_Density); //set projections vtProjection proj_new; proj_new.SetProjectionSimple(0, -1, EPSG_DATUM_WGS84); SetProjection(proj_new); // figure out the number of polygons in file uint size = 0; for (uint sec = 0; sec < pLULC->NumSections(); sec++) { section = pLULC->GetSection(sec); size = size + section->m_iNumPolys; } // Create density field m_field_density = m_pSet->AddField("Density", FT_Float); m_pSet->SetNumEntities(size); // get each poly from LULC file uint i, s, p, count = 0; float density=0; for (s = 0; s < pLULC->NumSections(); s++) { section = pLULC->GetSection(s); for (p = 0; p < section->m_iNumPolys; p++) { poly = section->m_pPoly + p; bool wild = false; switch (poly->Attribute) { case 42: // forest wild = true; density = 1.0f; break; case 32: case 33: wild = true; density = 0.5; break; case 22: // orchards wild = false; // no crops for now break; default: density = 0.0f; break; } DLine2 dline; dline.SetSize(poly->m_iCoords); // get Coords of LULCpoly and store as latlon, then save in VPoly for (i = 0; i < dline.GetSize(); i++) dline.SetAt(i, poly->m_p[i]); DPolygon2 dpoly; dpoly.push_back(dline); GetPS()->SetPolygon(count, dpoly); m_pSet->SetValue(count, m_field_density, density); count++; } } }