Ejemplo n.º 1
0
int main (int argc, char *argv[])
{
	char *configFile = NULL;
	char *outputFile = NULL;

	// Declare objects
	struct system System;
	struct tip Tip;
	struct space Space;
	struct graphene Graphene;
	struct substrate Substrate;

	initSystem(&System, &Tip, &Space, &Graphene, &Substrate);
	parseOptions(argc, argv, &configFile, &outputFile, &System, &Tip);
	parseFile(configFile, &System, &Tip, &Space, &Graphene, &Substrate);

	createSystem(&System, &Tip);
	createGraphene(&System, &Graphene);
//	transformCylindric(&System);
//	createSpace(&System, &Space);
	createTip(&System, &Tip);
	createSubstrate(&System, &Substrate);

	// Spheroidal Tip
	assignPointers(&System, &Tip, &Space, &Graphene, &Substrate);
	assignPotential(&System, &Tip, &Space, &Graphene, &Substrate);

	laplaceSpheroidal(&System, &Tip);

	retransformSpheroidal(&Tip);
	retransformCylindric(&System);

	saveData(outputFile, &System);

	// Visualize System if necessary
	if (System.visual)
	{
		initVisual();
		drawObjects(&System, &Tip, &Space, &Graphene, &Substrate);
	}

	free(System.points); // Free all points

	return EXIT_SUCCESS;
}
Ejemplo n.º 2
0
/* This function builds up the netlist representation from the checked
   netlist input.  It creates circuit components as necessary. */
void input::factory (void) {

  struct definition_t * def, * next;
  struct node_t * nodes;
  struct pair_t * pairs;
  circuit * c;
  object * o;
  analysis * a;
  substrate * s;
  nodeset * n;
  int i;

  // go through the list of input definitions
  for (def = definition_root; def != NULL; def = next) {
    next = def->next;
    // handle actions
    if (def->action) {
      if ((a = createAnalysis (def->type)) != NULL) {
	a->setName (def->instance);

	// add the properties to analysis
	for (pairs = def->pairs; pairs != NULL; pairs = pairs->next)
	  if (pairs->value->ident) {
	    if (pairs->value->var && strcmp (pairs->key, "Param")) {
	      variable * v;
	      if ((v = def->env->getVariable (pairs->value->ident)) != NULL) {
		// equation variable reference in analysis property
		a->addProperty (pairs->key, v);
	      }
	      else {
		// should not be reached!
		a->addProperty (pairs->key, pairs->value->ident);
	      }
	    }
	    else {
	      // ususal string property
	      a->addProperty (pairs->key, pairs->value->ident);
	    }
	  } else {
	    if (pairs->value->var) {
	      // add list sweeps and constants to the properties
	      variable * v = new variable (pairs->key);
	      constant * c = new constant (TAG_VECTOR);
	      c->v = createVector (pairs->value);
	      v->setConstant (c);
	      a->addProperty (pairs->key, v);
	    }
	    else {
	      a->addProperty (pairs->key, pairs->value->value);
	    }
	  }
	// additionally add missing optional properties
	assignDefaultProperties (a, def->define);
	a->setEnv (def->env);
	subnet->insertAnalysis (a);
      }
      // remove this definition from the list
      definition_root = netlist_unchain_definition (definition_root, def);
    }
  }

  // go through the list of input definitions
  for (def = definition_root; def != NULL; def = next) {
    next = def->next;
    // handle substrate definitions
    if (!def->action && def->substrate) {
      if ((s = createSubstrate (def->type)) != NULL) {
	s->setName (def->instance);

	// add the properties to substrate
	for (pairs = def->pairs; pairs != NULL; pairs = pairs->next)
	  if (pairs->value->ident) {
	    // a variable
	    if (pairs->value->var) {
	      // at this stage it should be ensured that the variable is
	      // already in the root environment
	      variable * v = def->env->getVariable (pairs->value->ident);
	      s->addProperty (pairs->key, v);
	    }
	    // a usual string property
	    else {
	      s->addProperty (pairs->key, pairs->value->ident);
	    }
	  } else {
	    s->addProperty (pairs->key, pairs->value->value);
	  }
	// additionally add missing optional properties
	assignDefaultProperties (s, def->define);

	// put new substrate definition into environment
	char * n = strrchr (def->instance, '.');
	variable * v = new variable (n ? n + 1 : def->instance);
	v->setSubstrate (s);
	def->env->addVariable (v);
      }
      // remove this definition from the list
      definition_root = netlist_unchain_definition (definition_root, def);
    }
    // handle nodeset definitions
    else if (!def->action && def->nodeset) {
      n = new nodeset ();
      n->setName (def->nodes->node);
      n->setValue (def->pairs->value->value);
      subnet->addNodeset (n);
      // remove this definition from the list
      definition_root = netlist_unchain_definition (definition_root, def);
    }
  }

  // go through the list of input definitions
  for (def = definition_root; def != NULL; def = next) {
    next = def->next;
    // handle component definitions
    if (!def->action && !def->substrate && !def->nodeset) {
      c = createCircuit (def->type);
      assert (c != NULL);
      o = (object *) c;
      c->setName (def->instance);
      c->setNonLinear (def->nonlinear != 0);
      c->setSubcircuit (def->subcircuit);

      // change size (number of ports) of variable sized components
      if (c->isVariableSized ()) {
	c->setSize (def->ncount);
      }
      // add appropriate nodes to circuit
      for (i = 0, nodes = def->nodes; nodes; nodes = nodes->next, i++)
	if (i < c->getSize ())
	  c->setNode (i, nodes->node);

      // add the properties to circuit
      for (pairs = def->pairs; pairs != NULL; pairs = pairs->next) {
	if (pairs->value == NULL) {
	  // zero-length value lists
	  variable * v = new variable (pairs->key);
	  constant * c = new constant (TAG_VECTOR);
	  c->v = new vector ();
	  v->setConstant (c);
	  o->addProperty (pairs->key, v);
	}
	else if (pairs->value->ident) {
	  if (pairs->value->var) {
	    // at this stage it should be ensured that the variable is
	    // already in the root environment
	    variable * v = def->env->getVariable (pairs->value->ident);
	    o->addProperty (pairs->key, v);
	  } else {
	    if (pairs->value->subst) {
	      variable * v = def->env->getVariable (pairs->value->ident);
	      c->setSubstrate (v->getSubstrate ());
	    }
	    o->addProperty (pairs->key, pairs->value->ident);
	  }
	} else {
	  if (pairs->value->var) {
	    // add value lists to the properties
	    variable * v = new variable (pairs->key);
	    constant * c = new constant (TAG_VECTOR);
	    c->v = createVector (pairs->value);
	    v->setConstant (c);
	    o->addProperty (pairs->key, v);
	  } else {
	    o->addProperty (pairs->key, pairs->value->value);
	  }
	}
      }
      // set local circuit environment
      c->setEnv (def->env);

      // additionally add missing optional properties
      assignDefaultProperties (c, def->define);

      // insert the circuit into the netlist object
      subnet->insertCircuit (c);

      // remove this definition from the list
      definition_root = netlist_unchain_definition (definition_root, def);
    }
  }
}