SIMION® Industry standard charged particle optics simulation software.
Newsflash: SIMION 8.1.1 is here: dielectrics, new examples + preview of permeability; ASMS2012 posters; major improvements to enhanced surface accuracy feature coming soon (details in Check for Updates).
About | Documentation | Community/Support | Downloads | Ordering

SL Libraries -- C++

The SIMION SL™ Toolkit (version 1.2.1.0 - 2004-11-09)

swirl.cpp

Go to the documentation of this file.
00001 /** 00002 * @file swirl.cpp 00003 * This generates a potential array file describing a swirl-like 00004 * shape (e.g. a ribbon wrapped around a cylinder). 00005 * 00006 * David Manura, Scientific Instrument Services, Inc. 00007 * $Revision: 1.4 $ $Date: 2004/07/17 20:48:51 $ Created 2003-11. 00008 */ 00009 00010 #include <iostream> 00011 #include <cmath> 00012 00013 #include <simion/pa.h> // SL potential array class 00014 //#include <simion/pa.cpp> 00015 using namespace std; 00016 using namespace simion; 00017 00018 const double pi = 3.141592; 00019 00020 int main() 00021 { 00022 cout << "Generating swirl.pa# file....\n"; 00023 00024 // create array in memory 00025 PA pa(PAArgs().nx(100).ny(100).nz(100)); 00026 00027 // iterate over all points 00028 for(int x = 0; x < pa.nx(); x++) { 00029 for(int y = 0; y < pa.ny(); y++) { 00030 for(int z = 0; z < pa.nz(); z++) { 00031 // compute polar coordinates 00032 int dx = x - 50; 00033 int dy = y - 50; 00034 double radius = sqrt((double)(dx * dx + dy * dy)); 00035 double theta = atan2((double)dy, (double)dx); // -PI..PI 00036 00037 double omega = pi + theta + (double)z/5; 00038 // wrap omega to range 0..2*PI 00039 while(omega >= 2*pi) 00040 omega -= 2*pi; 00041 00042 bool is_electrode = (radius > 30 && radius < 35 && omega < 2); 00043 double voltage = 1; 00044 00045 // set point value 00046 if(is_electrode) pa.point(x, y, z, true, voltage); 00047 }}} // end loops 00048 00049 // save to file 00050 pa.save("swirl.pa#"); 00051 00052 cout << "done\n"; 00053 00054 return 0; 00055 } 00056
(c) 2003-2004. Scientific Instrument Services, Inc. All Rights Reserved.
Please report any errors/comments regarding this web page:
  Name/e-mail/phone (optional):
 
The SIMION SL Toolkit™ and documentation is (c) 2003-2004 Scientific Instrument Services, Inc. All Rights Reserved.
Any comments on this web page? (will be sent to SIS)
[Optional] Your name: email: phone/fax:
The SL Tookit™ and documentation is (c) 2003 Scientific Instrument Services, Inc. All Rights Reserved.
(c) 2003-2006 Scientific Instrument Services, Inc. (SIS). Contact SIS.