public void Test() { using (var store = NewDocumentStore()) { store.Initialize(); store.JsonRequestFactory.RequestTimeout = TimeSpan.FromHours(1); new RavenDocumentsByEntityName().Execute(store); using (var session = store.OpenSession()) { var compound = new Compound { Id = "compound/1", ReferenceNumber = "b", Compounds = { new Compound { ReferenceNumber = "c" } } // Comment this line out to make the test work }; session.Store(compound); session.SaveChanges(); } var script = @"if (this.ReferenceNumber == 'a'){ this.ReferenceNumber = 'Aa'; }"; var operation = store.DatabaseCommands.UpdateByIndex( "Raven/DocumentsByEntityName", new IndexQuery { Query = "Tag:Compounds" }, new ScriptedPatchRequest { Script = script }, new BulkOperationOptions { AllowStale = false, StaleTimeout = TimeSpan.MaxValue, RetrieveDetails = true }); var patchResult = operation.WaitForCompletion(); Assert.False(patchResult.ToString().Contains("Patched")); } }
static void Main(string[] args) { Compound comp = new Compound("Water"); comp.Display(); Compound legComp = new AdapterCompound("Benzene"); legComp.Display(); }
private void AddClassData(Compound _compound, TemplateInfo _info, ClassInfo _classInfo, FileData _outputFile) { List<CompoundFunction> funtions = new List<CompoundFunction>(); List<Pair<CompoundFunction, CompoundFunction>> properties = new List<Pair<CompoundFunction, CompoundFunction>>(); List<CompoundVariable> variables = new List<CompoundVariable>(); foreach (Compound child in _compound) { if (child is CompoundFunction) { CompoundFunction func = (CompoundFunction)child; if (GetAviableFunc(func)) { if ( //func.Const && func.CompoundParamTypes.Count == 0 && func.CompoundType.TypeName != "void" && (func.GetProperty || func.IsProperty)) properties.Add(new Pair<CompoundFunction, CompoundFunction>(func, null)); else funtions.Add(func); } } else if (child is CompoundVariable) { CompoundVariable variable = (CompoundVariable)child; if (variable.Public && !variable.Static && !variable.Name.StartsWith("_") && CompoundUtility.IsVariableEvent(variable)) { variables.Add(variable); } } } // вытаскиваем сетеры для свойств из списка функций foreach (var func in properties) func.Second = PopSetterFunc(func.First, funtions); foreach (var func in properties) AddClassProperty(func, _info, _classInfo, _outputFile); foreach (var func in funtions) AddClassFunction(func, _info, _classInfo, _outputFile); foreach (var variable in variables) AddClassEvent(variable, _info, _classInfo, _outputFile); }
static void Main(string[] args) { // Non-adapted chemical compound Compound unknown = new Compound("Unknown"); unknown.Display(); // Adapted chemical compounds Compound water = new RichCompound("Water"); water.Display(); Compound benzene = new RichCompound("Benzene"); benzene.Display(); Compound ethanol = new RichCompound("Ethanol"); ethanol.Display(); // Wait for user Console.ReadKey(true); }
internal CompoundView(Compound compound, int viewPosition) : base(_nextObjectId++) { Compound = compound; ViewPosition = viewPosition; CompoundContextCache = new ValueCache<CompoundContext> (() => new CompoundContext(this)); _typeCache = new ValueCache<CompoundType>(() => new CompoundType(this)); _accessFeaturesCache = new FunctionCache<int, AccessFeature> (position => new AccessFeature(this, position)); _fieldAccessTypeCache = new FunctionCache<int, FieldAccessType> (position => new FieldAccessType(this, position)); _functionBodyTypeCache = new FunctionCache<FunctionSyntax, FunctionBodyType> (syntax => new FunctionBodyType(this, syntax)); StopByObjectIds(); }
/// <summary> /// The orientation of the non-tranformed LumpedPort and the normal /// direction of its excitation vector should match. /// </summary> //[Fact(Skip="Disable output while developing other test cases")] public void LumpedPort_WithoutTransformation_NormalDirectionCorrect() { Compound excitation = new Compound("Excitation"); LumpedPort lumpedPort = new LumpedPort(0, 1, 50, new Vector3D(), new Vector3D(1, 1, 1), ENormDir.X); excitation.Add(lumpedPort); Assert.True(false, "Test not implemented yet"); }
private void ParseCompoundByNodeName(XmlNode _node, Compound _parent, string _name) { foreach (XmlNode node in _node.SelectNodes(_name)) { string type = node.Attributes["kind"].Value; if (!IsTypeIgnored(type)) { var compound = mFatory.CreateCompound(type); if (compound != null) { compound.Initialise(node); if (!IsNameIgnored(compound.Name)) { RegisterCompound(compound); _parent.AddChild(compound); InitialiseCompounds(node, compound); } else { AddToIgnoredList(compound); } } } } }
private void addPartialProcesses <TPartialProcess, TIndividualMolecule, TProcessSelection>(Compound compound, Individual individual, ProcessSelectionGroup processSelectionGroup) where TPartialProcess : PartialProcess where TIndividualMolecule : IndividualMolecule where TProcessSelection : ProcessSelection, new() { //default mapping with processes: Mapping done only by name foreach (var process in compound.AllProcesses <TPartialProcess>()) { var molecule = individual.MoleculeByName <TIndividualMolecule>(process.MoleculeName); //enzyme not found in individual if (molecule == null) { continue; } processSelectionGroup.AddPartialProcessSelection(new TProcessSelection { ProcessName = process.Name, MoleculeName = molecule.Name, CompoundName = compound.Name }); } }
private Compound getCompound(XmlElement xmlcompound) { // for each <version> element get basic details // and what implements it Compound compound = new Compound(); compound.name = xmlcompound.GetAttribute("name"); compound.istemplate = xmlcompound.GetAttribute("istemplate"); compound.niflibtype = xmlcompound.GetAttribute("niflibtype"); compound.nifskopetype = xmlcompound.GetAttribute("nifskopetype"); if ((xmlcompound.HasChildNodes) && (xmlcompound.FirstChild.NodeType == XmlNodeType.Text)) compound.description = xmlcompound.FirstChild.Value.Trim(); else compound.description = ""; //get a nodelist of elements XmlNodeList xmladdlist = xmlcompound.GetElementsByTagName("add"); if (xmladdlist != null && xmladdlist.Count > 0) { foreach (XmlElement add in xmladdlist) { compound.AddAdd(add.GetAttribute("name"), add.InnerText, add.GetAttribute("ver1"), add.GetAttribute("ver2"), add.GetAttribute("type"), add.GetAttribute("arr1"), add.GetAttribute("arr2"), add.GetAttribute("arr2"), add.GetAttribute("default"), add.GetAttribute("template"), add.GetAttribute("userver"), add.GetAttribute("cond"), add.GetAttribute("arg")); } } return compound; }
private void AddToIgnoredList(Compound _compound) { mIgnoredItems.Add(_compound); }
private void AddBase(Compound _compound) { mBaseClases.Add(_compound); }
private void DoWrappTemplate(TemplateInfo _info, ClassInfo _classInfo, Compound _compound) { FileData outputFile = mOutputManager.GetOutputFile(_info.Output); if (outputFile.Data.Length == 0) { FileData template = mTemplateManager.GetTemplateCopy(GetTemplateFileName(_info.TemplateFolder, _info.OutputTemplate)); mReplaceManager.DoReplace(template, new IReplacer[] { _classInfo }); AppendData(outputFile, template); } if (_info.Template != "") { FileData template = mTemplateManager.GetTemplateCopy(GetTemplateFileName(_info.TemplateFolder, _info.Template)); mReplaceManager.DoReplace(template, new IReplacer[] { _classInfo }); InsertData(outputFile, template, mLabelName); } else { AddClassData(_compound, _info, _classInfo, outputFile); } }
private void GenerateDirectivitySimulationInput() { // Constants double unit = 1e-3; double c0 = 299792458.0; double lambda0 = c0 / m_f0; double lambdaMin = c0 / (m_f0 + m_fc); Compound simulationSpace = new Compound("space"); Compound solidSpace = new Compound("solid-space"); simulationSpace.Add(solidSpace); Compound dut; if (m_excludeEndo == true) { dut = m_endo.GetModule(m_slotIndex); } else { dut = m_endo; } solidSpace.Add(dut); // modifies dut parent (!) // Set up simulation grid, nf2ff and SAR Logger.WriteInfo("Constructing FDTD simulation grid..."); double airBox = 40; double maxRes = Math.Round(lambdaMin / 20 / unit); double maxRatio = 1.5; RectilinearGrid grid = new RectilinearGrid(); grid.Add(dut.BoundingBox.P1); grid.Add(dut.BoundingBox.P2); #region openems_workaround // openEMS v0.0.31 seems to handle transformations on excitation (lumped port), // SAR and NF2FF simulation components incorrectly. // Applied workarounds: // 1. The entire design is moved so that the antenna feedpoint is in the origin // 2. The SAR and NF2FF boxes are added late, w/o transformations Vector3D antennaPosition = new Vector3D( m_antenna.AbsoluteTransformation.X, m_antenna.AbsoluteTransformation.Y, m_antenna.AbsoluteTransformation.Z); solidSpace.Transformations.Add(new TTranslate(-antennaPosition)); grid.Move(-antennaPosition); grid.Add(new Vector3D(0, 0, 0)); grid.ZLines.Add(-(m_antenna.Parent as CSXCAD.Ara.PCB).Thickness); grid.Sort(); grid.SmoothMesh(m_dutResolution, maxRatio); grid.AddAirbox(airBox); grid.SmoothMesh(maxRes, maxRatio); simulationSpace.Add(new NF2FFBox("nf2ff", new Vector3D(grid.XLines.First(), grid.YLines.First(), grid.ZLines.First()), new Vector3D(grid.XLines.Last(), grid.YLines.Last(), grid.ZLines.Last()), lambdaMin / 15 / unit)); #endregion grid.AddPML(8); Simulation fdtd = new Simulation(); fdtd.Excitation = new GaussExcitation(m_f0, m_fc); // Export XDocument doc = new XDocument( new XDeclaration("1.0", "utf-8", "yes"), new XComment("CyPhy generated openEMS simulation file"), new XElement("openEMS", fdtd.ToXElement(), new XElement("ContinuousStructure", new XAttribute("CoordSystem", 0), simulationSpace.ToXElement(), grid.ToXElement() ) ) ); if (dut is CSXCAD.Ara.Module) { dut.Parent = m_endo; } string openEmsInput = Path.Combine(mainParameters.OutputDirectory, "openEMS_input.xml"); doc.Save(openEmsInput); string nf2ffInput = Path.Combine(mainParameters.OutputDirectory, "nf2ff_input.xml"); var nf2ff = new Postprocess.NF2FF(m_f0); nf2ff.ToXDocument().Save(nf2ffInput); }
private void GenerateSarSimulationInput() { // Constants double unit = 1e-3; double c0 = 299792458.0; double lambda0 = c0 / m_f0; double f_c = 500e6; double lambdaMin = c0 / (m_f0 + f_c); Compound simulationSpace = new Compound("space"); Compound solidSpace = new Compound("solid-space"); simulationSpace.Add(solidSpace); solidSpace.Add(m_endo); var headPhantom = new CSXCAD.Ara.HeadPhantom(); headPhantom.Transformations.Add(new TRotateX(Math.PI / 2)); headPhantom.Transformations.Add(new TTranslate(32.0, 80.0, -headPhantom.Width / 2 - 7.0)); // TODO: Make endo width/height accessibles solidSpace.Add(headPhantom); // Set up simulation grid, nf2ff and SAR Logger.WriteInfo("Constructing FDTD simulation grid..."); double airBox = 40; double envResolution = Math.Round(lambdaMin / 20 / unit); double maxRatio = 1.5; RectilinearGrid grid = new BoundingGrid_6x3(); #region openems_workaround // openEMS v0.0.31 seems to handle transformations on excitation (lumped port), // SAR and NF2FF simulation components incorrectly. // Applied workarounds: // 1. The entire design is moved so that the antenna feedpoint is in the origin // 2. The SAR and NF2FF boxes are added late, w/o transformations Vector3D dutPosition = new Vector3D( m_antenna.AbsoluteTransformation.X, m_antenna.AbsoluteTransformation.Y, m_antenna.AbsoluteTransformation.Z); solidSpace.Transformations.Add(new TTranslate(-dutPosition)); grid.Move(-dutPosition); grid.Add(new Vector3D(0, 0, 0)); grid.ZLines.Add(-(m_antenna.Parent as CSXCAD.Ara.PCB).Thickness); grid.Sort(); grid.SmoothMesh(m_dutResolution, maxRatio); grid.Add(headPhantom.BoundingBox.P1); grid.Add(headPhantom.BoundingBox.P2); grid.SmoothMesh(m_sarResolution, maxRatio); grid.AddAirbox(airBox); grid.SmoothMesh(envResolution, maxRatio); simulationSpace.Add(new SARBox("SAR", m_f0, new Vector3D(headPhantom.XGridPoints.First(), headPhantom.YGridPoints.First(), headPhantom.ZGridPoints.First()), new Vector3D(headPhantom.XGridPoints.Last(), headPhantom.YGridPoints.Last(), headPhantom.ZGridPoints.Last()))); simulationSpace.Add(new NF2FFBox("nf2ff", new Vector3D(grid.XLines.First(), grid.YLines.First(), grid.ZLines.First()), new Vector3D(grid.XLines.Last(), grid.YLines.Last(), grid.ZLines.Last()), lambdaMin / 15 / unit)); #endregion grid.AddPML(8); Simulation fdtd = new Simulation(); fdtd.Excitation = new GaussExcitation(m_f0, m_fc); // Export XDocument doc = new XDocument( new XDeclaration("1.0", "utf-8", "yes"), new XComment("CyPhy generated openEMS simulation file"), new XElement("openEMS", fdtd.ToXElement(), new XElement("ContinuousStructure", new XAttribute("CoordSystem", 0), simulationSpace.ToXElement(), grid.ToXElement() ) ) ); string openEmsInput = Path.Combine(mainParameters.OutputDirectory, "openEMS_input.xml"); doc.Save(openEmsInput); string nf2ffInput = Path.Combine(mainParameters.OutputDirectory, "nf2ff_input.xml"); var nf2ff = new Postprocess.NF2FF(m_f0); nf2ff.ToXDocument().Save(nf2ffInput); }
/// <summary> /// Tries to find specified compound as close to the point as possible. /// </summary> /// <param name="position">Position to search around</param> /// <param name="compound">What compound to search for</param> /// <param name="searchRadius">How wide to search around the point</param> /// <param name="minConcentration">Limits search to only find concentrations higher than this</param> /// <returns>The nearest found point for the compound or null</returns> public Vector3?FindCompoundNearPoint(Vector3 position, Compound compound, float searchRadius = 200, float minConcentration = 120) { if (searchRadius < 1) { throw new ArgumentException("searchRadius must be >= 1"); } int resolution = Resolution; // This version is used when working with cloud local coordinates float localRadius = searchRadius / resolution; float localRadiusSquared = Mathf.Pow(searchRadius / resolution, 2); float nearestDistanceSquared = float.MaxValue; Vector3?closestPoint = null; foreach (var cloud in clouds) { // Skip clouds that don't handle the target compound if (!cloud.HandlesCompound(compound)) { continue; } // Skip clouds that are out of range if (!cloud.ContainsPositionWithRadius(position, searchRadius)) { continue; } cloud.ConvertToCloudLocal(position, out var cloudRelativeX, out var cloudRelativeY); // For simplicity all points within a bounding box around the // relative origin point is calculated and that is restricted by // checking if the point is within the circle before grabbing // And apparently there isn't an algorithm to generate the points with closest ones first? so // this goes through everything and keeps the closest found point int xEnd = (int)Mathf.Round(cloudRelativeX + localRadius); int yEnd = (int)Mathf.Round(cloudRelativeY + localRadius); for (int x = (int)Mathf.Round(cloudRelativeX - localRadius); x <= xEnd; x += 1) { for (int y = (int)Mathf.Round(cloudRelativeY - localRadius); y <= yEnd; y += 1) { // Negative coordinates are always outside the cloud area if (x < 0 || y < 0) { continue; } // Circle check if (Mathf.Pow(x - cloudRelativeX, 2) + Mathf.Pow(y - cloudRelativeY, 2) > localRadiusSquared) { // Not in it continue; } // Then just need to check that it is within the cloud simulation array if (x < cloud.Size && y < cloud.Size) { if (cloud.AmountAvailable(compound, x, y) >= minConcentration) { // Potential target point var currentWorldPos = cloud.ConvertToWorld(x, y); var distance = (position - currentWorldPos).LengthSquared(); if (distance < nearestDistanceSquared) { closestPoint = currentWorldPos; nearestDistanceSquared = distance; } } } } } } return(closestPoint); }
/// <summary> /// Resets the cloud contents and positions as well as the compound types they store /// </summary> public void Init(FluidSystem fluidSystem) { allCloudCompounds = SimulationParameters.Instance.GetCloudCompounds(); if (!IsLoadedFromSave) { clouds.Clear(); } // Count the number of clouds needed at one position from the loaded compound types neededCloudsAtOnePosition = (int)Math.Ceiling(allCloudCompounds.Count / (float)Constants.CLOUDS_IN_ONE); // We need to dynamically spawn more / delete some if this doesn't match while (clouds.Count < neededCloudsAtOnePosition) { var createdCloud = (CompoundCloudPlane)cloudScene.Instance(); clouds.Add(createdCloud); AddChild(createdCloud); } // TODO: this should be changed to detect which clouds are safe to delete while (clouds.Count > neededCloudsAtOnePosition) { var cloud = clouds[clouds.Count - 1]; RemoveChild(cloud); cloud.Free(); clouds.Remove(cloud); } // TODO: if the compound types have changed since we saved, that needs to be handled if (IsLoadedFromSave) { foreach (var cloud in clouds) { // Re-init with potentially changed compounds // TODO: special handling is needed if the compounds actually changed cloud.Init(fluidSystem, cloud.Compounds[0], cloud.Compounds[1], cloud.Compounds[2], cloud.Compounds[3]); // Re-add the clouds as our children AddChild(cloud); } return; } for (int i = 0; i < clouds.Count; ++i) { Compound cloud1; Compound cloud2 = null; Compound cloud3 = null; Compound cloud4 = null; int startOffset = (i % neededCloudsAtOnePosition) * Constants.CLOUDS_IN_ONE; cloud1 = allCloudCompounds[startOffset + 0]; if (startOffset + 1 < allCloudCompounds.Count) { cloud2 = allCloudCompounds[startOffset + 1]; } if (startOffset + 2 < allCloudCompounds.Count) { cloud3 = allCloudCompounds[startOffset + 2]; } if (startOffset + 3 < allCloudCompounds.Count) { cloud4 = allCloudCompounds[startOffset + 3]; } clouds[i].Init(fluidSystem, cloud1, cloud2, cloud3, cloud4); clouds[i].Translation = new Vector3(0, 0, 0); } }
private ISchemaItem singleDosingItem(Simulation simulation, Compound compound) { return(schemaItemsFrom(simulation, compound)[0]); }
private bool isMultipleOral(Simulation simulation, Compound compound) { var allSchemaItems = schemaItemsFrom(simulation, compound); return(allSchemaItems.Any() && allSchemaItems.All(isOral)); }
void OnGUI() { EditorGUILayout.BeginVertical(); scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition, GUILayout.Width(0), GUILayout.Height(0)); EditorGUILayout.LabelField("Deletar Produto:"); Dictionary <string, Compound> products = CompoundFactory.GetInstance().Collection; string[] names = new string[products.Count]; int counter = 0; foreach (string name in products.Keys) { names[counter] = name; counter++; } indexOfProduct = EditorGUILayout.Popup(indexOfProduct, names); selectedProduct = names[indexOfProduct]; if (selectedProduct != selectedProductLastInteraction) { selected = false; } selectedProductLastInteraction = selectedProduct; if (!selected) { if (GUILayout.Button("Checar")) { selected = true; deleteSelected = false; product = products[names[indexOfProduct]] as Compound; } } if (selected) { EditorGUILayout.LabelField("Nome: " + product.Name); EditorGUILayout.LabelField("Massa Molar : " + product.MolarMass.ToString()); EditorGUILayout.LabelField("Densidade : " + product.Density.ToString()); EditorGUILayout.LabelField("Purity : " + product.Purity.ToString()); EditorGUILayout.LabelField("Polaridade: " + product.Polarizability.ToString()); EditorGUILayout.LabelField("Condutividade: " + product.Conductibility.ToString()); EditorGUILayout.LabelField("Solubilidade: " + product.Solubility.ToString()); if (!product.IsSolid) { EditorGUILayout.LabelField("Ph : " + (product as Compound).PH.ToString()); EditorGUILayout.LabelField("Turbilidade: " + (product as Compound).Turbidity.ToString()); EditorGUILayout.LabelField("Refratometro: " + (product as Compound).Refratometer.ToString()); EditorGUILayout.LabelField("Espectro de Chama: " + product.FlameSpecter); if ((product as Compound).hplc != null) { EditorGUILayout.LabelField("HPLC = " + (product as Compound).hplc.ToString()); } else { EditorGUILayout.LabelField("HPLC = "); } } if (product.irSpecter != null) { EditorGUILayout.LabelField("Espectro IR : " + product.irSpecter.name); } else { EditorGUILayout.LabelField("Espectro IR : "); } if (product.uvSpecter != null) { EditorGUILayout.LabelField("Espectro UV : " + product.uvSpecter.name); } else { EditorGUILayout.LabelField("Espectro UV : "); } /* if(product.texture != null) * { * EditorGUILayout.LabelField("Textura: " + product.texture.name); * } * else * { * EditorGUILayout.LabelField("Textura: "); * }*/ EditorGUILayout.ColorField("Cor: ", product.compoundColor); if (!deleteSelected) { if (GUILayout.Button("DELETAR!")) { deleteSelected = true; } } else { EditorGUILayout.LabelField("Deletar?"); if (GUILayout.Button("Sim")) { Dictionary <string, Compound> allProducts = CompoundFactory.GetInstance().CupboardCollection; allProducts.Remove(names[indexOfProduct]); // ComponentsSaver.SaveProducts(allProducts); Debug.Log("Produto " + names[indexOfProduct] + " Removido com sucesso!"); this.Close(); } if (GUILayout.Button("Nao")) { this.Close(); } } } EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); }
private XDocument BuildDipoleSarXml() { double unit = 1e-3; double f0 = 1e9; double c0 = 299792458.0; double lambda0 = c0 / f0; double fStop = 1.5e9; double lambdaMin = c0 / fStop; // Simulation engine Simulation fdtd = new Simulation(); fdtd.Excitation = new GaussExcitation(0, fStop); // possible typo in Dipole_SAR.xml // Simulation space Compound s = new Compound("space"); // Dipole antenna double dipoleLength = 0.46 * lambda0 / unit; s.Add(new Box(null, new Metal("Dipole"), 1, new Vector3D(0, 0, -dipoleLength / 2), new Vector3D(0, 0, dipoleLength / 2))); // Phantom Compound headPhantom = new Compound("head-phantom"); Dielectric skinMaterial = new Dielectric("skin", 50, kappa: 0.65, density: 1100); skinMaterial.FillColor = new Material.Color(245, 215, 205, 250); skinMaterial.EdgeColor = new Material.Color(255, 235, 217, 250); Sphere skin = new Sphere(null, skinMaterial, 11, new Vector3D(), 1); skin.Transformations.Add(new TScale(80, 100, 100)); headPhantom.Add(skin); Dielectric boneMaterial = new Dielectric("headbone", 13, kappa: 0.1, density: 2000); boneMaterial.FillColor = new Material.Color(227, 227, 227, 250); boneMaterial.EdgeColor = new Material.Color(202, 202, 202, 250); Sphere bone = new Sphere(null, boneMaterial, 12, new Vector3D(), 1); bone.Transformations.Add(new TScale(75, 95, 95)); headPhantom.Add(bone); Dielectric brainMaterial = new Dielectric("brain", 60, kappa: 0.7, density: 1040); brainMaterial.FillColor = new Material.Color(255, 85, 127, 250); brainMaterial.EdgeColor = new Material.Color(71, 222, 179, 250); Sphere brain = new Sphere(null, brainMaterial, 13, new Vector3D(), 1); brain.Transformations.Add(new TScale(65, 85, 85)); headPhantom.Add(brain); headPhantom.Transformations.Add(new TTranslate(100, 0, 0)); s.Add(headPhantom); // Excitation double meshResAir = lambdaMin / 20 / unit; double meshResPhantom = 2.5; LumpedPort lp = new LumpedPort(100, 1, 50.0, new Vector3D(-0.1, -0.1, -meshResPhantom / 2), new Vector3D(+0.1, +0.1, +meshResPhantom / 2), ENormDir.Z, true); s.Add(lp); // Grid RectilinearGrid g = new RectilinearGrid(); g.XLines.Add(0); g.YLines.Add(0); foreach (double z in new double[] { -1.0 / 3, 2.0 / 3 }) { g.ZLines.Add(-dipoleLength / 2 - meshResPhantom * z); g.ZLines.Add(+dipoleLength / 2 + meshResPhantom * z); } foreach (Sphere sp in new Sphere[] { skin, bone, brain }) { g.XLines.Add(sp.AbsoluteTransformation.Matrix[0, 3] + sp.AbsoluteTransformation.Matrix[0, 0]); g.XLines.Add(sp.AbsoluteTransformation.Matrix[0, 3] - sp.AbsoluteTransformation.Matrix[0, 0]); g.YLines.Add(sp.AbsoluteTransformation.Matrix[1, 3] + sp.AbsoluteTransformation.Matrix[1, 1]); g.YLines.Add(sp.AbsoluteTransformation.Matrix[1, 3] - sp.AbsoluteTransformation.Matrix[1, 1]); g.ZLines.Add(sp.AbsoluteTransformation.Matrix[2, 3] + sp.AbsoluteTransformation.Matrix[2, 2]); g.ZLines.Add(sp.AbsoluteTransformation.Matrix[2, 3] - sp.AbsoluteTransformation.Matrix[2, 2]); } g.ZLines.Add(-meshResPhantom / 2); // port g.ZLines.Add(+meshResPhantom / 2); // Mesh over dipole and phantom g.SmoothMesh(meshResPhantom); g.XLines.Add(-200); g.XLines.Add(250 + 100); g.YLines.Add(-250); g.YLines.Add(+250); g.ZLines.Add(-250); g.ZLines.Add(+250); g.SmoothMesh(meshResAir, 1.2); s.Add(new SARBox("SAR", f0, new Vector3D(-10, -100, -100), new Vector3D(180, 100, 100))); s.Add(new NF2FFBox("nf2ff", new Vector3D(g.XLines.First(), g.YLines.First(), g.ZLines.First()), new Vector3D(g.XLines.Last(), g.YLines.Last(), g.ZLines.Last()), lambdaMin / 15 / unit)); g.AddPML(10); g.XLines.Sort(); g.YLines.Sort(); g.ZLines.Sort(); // Export return new XDocument( new XDeclaration("1.0", "utf-8", "yes"), new XComment("Test XML file for CyPhy generated openEMS simulations"), new XElement("openEMS", fdtd.ToXElement(), new XElement("ContinuousStructure", new XAttribute("CoordSystem", 0), s.ToXElement(), g.ToXElement() ) ) ); }
private void VisitPorts(CyPhyInterfaces.RFPort currentPort, CyPhyInterfaces.RFPort prevPort) { if (m_rfModelFound) { return; } if (CodeGenerator.verbose) Logger.WriteInfo("Current port: " + currentPort.Name + " (" + currentPort.ID + ") parent: " + currentPort.ParentContainer.Name); if (currentPort.ParentContainer.Kind == "RFModel") { m_rfModelFound = true; // Add excitation CyPhyInterfaces.RFModel rfModel = CyPhyClasses.RFModel.Cast(currentPort.ParentContainer.Impl); CSXCAD.Ara.Module m = m_endo.GetModule(m_slotIndex); CSXCAD.Compound excitation = new Compound(null, "Excitation", new Vector3D(rfModel.Attributes.X, rfModel.Attributes.Y, m.PCB.Thickness), (double)rfModel.Attributes.Rotation * Math.PI / 2); excitation.Add(new LumpedPort(100, 1, 50.0, new Vector3D(0, 0, -m.PCB.Thickness), new Vector3D(0, 0, 0), ENormDir.Z, true)); m.PCB.Add(excitation); return; } var portQuery = (prevPort == null) ? (from p in currentPort.SrcConnections.PortCompositionCollection select p.SrcEnd).Union( from p in currentPort.DstConnections.PortCompositionCollection select p.DstEnd) : (from p in currentPort.SrcConnections.PortCompositionCollection where p.SrcEnd.ID != prevPort.ID select p.SrcEnd).Union( from p in currentPort.DstConnections.PortCompositionCollection where p.DstEnd.ID != prevPort.ID select p.DstEnd); foreach (CyPhyClasses.RFPort nextPort in portQuery) { VisitPorts(nextPort, currentPort); } }
public Coil(Compound parent, string name, Vector3D pos, double rot) : base(parent, name, pos, rot) { Priority = EPM.m_priority - 1; Material = DefaultMaterial; Material.FillColor = new Material.Color(235, 148, 7, 255); Material.EdgeColor = new Material.Color(235, 148, 7, 255); LinearPolygon neodymium = new LinearPolygon(this, this.Material, this.Priority, 0, m_d, new double[,] { { 2.6 - m_thickness, 2.6 - m_thickness, 5.11 + m_thickness, 5.11 + m_thickness }, { 0.91 - m_thickness, 2.38 + m_thickness, 2.38 + m_thickness, 0.91 - m_thickness} }, m_width-2*m_d); m_primitives.Add(neodymium); }
CompoundView CreateView(Compound target) => target == null ? null : new CompoundView(target, this);
// Initliaze the Compounds with Initial Values public void IniCompounds() { for(int i = 0; i < _Compound.Length; i++) { _Compound[i] = new Compound(); _Compound[i].Name = ((CompoundName)i).ToString(); // Assign Max and Current values to the coumpound array if(_Compound[i].Name == "ATP") { _Compound[i].CurValue = _atpCurValueINI; _Compound[i].MaxValue = _atpMaxValueINI; } else if(_Compound[i].Name == "Oxygen") { _Compound[i].CurValue = _oxygenCurValueINI; _Compound[i].MaxValue = _oxygenMaxValueINI; _Compound[i].LimValue = false; _Compound[i].MinIntake = 0.5f; _Compound[i].MaxIntake = 1.5f; } else if(_Compound[i].Name == "Sugar") { _Compound[i].CurValue = _sugarCurValueINI; _Compound[i].MaxValue = _sugarMaxValueINI; } else if(_Compound[i].Name == "AminoAcids") { _Compound[i].CurValue = _aminoAcidsCurValueINI; _Compound[i].MaxValue = _aminoAcidsMaxValueINI; } else if(_Compound[i].Name == "Protein") { _Compound[i].CurValue = _proteinCurValueINI; _Compound[i].MaxValue = _proteinMaxValueINI; } else if(_Compound[i].Name == "Fat") { _Compound[i].CurValue = _fatCurValueINI; _Compound[i].MaxValue = _fatMaxValueINI; } else if(_Compound[i].Name == "Water") { _Compound[i].CurValue = _waterCurValueINI; _Compound[i].MaxValue = _waterMaxValueINI; _Compound[i].LimValue = false; _Compound[i].MinIntake = 0.0f; _Compound[i].MaxIntake = 1.0f; } else if(_Compound[i].Name == "CO2") { _Compound[i].CurValue = _co2CurValueINI; _Compound[i].MaxValue = _co2MaxValueINI; _Compound[i].LimValue = false; _Compound[i].MinIntake = -1.0f; _Compound[i].MaxIntake = -2.0f; } else if(_Compound[i].Name == "Ammonia") { _Compound[i].CurValue = _co2CurValueINI; //TO update _Compound[i].MaxValue = _co2MaxValueINI; //TO update _Compound[i].LimValue = false; } } }
public static void Main(string[] args) { // Retrieve and display water characteristics Compound water = new Compound( "Water" ); water.Display(); // Retrieve and display benzene characteristics Compound benzene = new Compound( "Benzene" ); benzene.Display(); // Retrieve and display alcohol characteristics Compound alcohol = new Compound( "Alcohol" ); alcohol.Display(); Console.Read(); }
public Neodymium(Compound parent, string name, Vector3D pos, double rot) : base(parent, name, pos, rot) { Priority = EPM.m_priority; Material = DefaultMaterial; Material.FillColor = new Material.Color(55, 55, 65, 255); Material.EdgeColor = new Material.Color(55, 55, 65, 255); LinearPolygon neodymium = new LinearPolygon(this, this.Material, this.Priority, 0, 0, new double[,] { { 0, 0, 2, 2 }, { 0, 2.38, 2.38, 0} }, m_width); m_primitives.Add(neodymium); }
//TODO: Prevent exchange when the compound hit his desired value // Exhange Compounds with environment at a rate between the MinIntake and the MaxIntake function of the Compound level in the water private void _ExchangeCompound(Compound __CurCompound) { double __randomValue; if(__CurCompound.MinIntake != 0.0f || __CurCompound.MaxIntake != 0.0f) { __randomValue = UnityEngine.Random.Range(__CurCompound.MinIntake, __CurCompound.MaxIntake); __CurCompound.CurValue += (int)Math.Round(__randomValue); } }
public void RegisterCompound(Compound _compound) { if (mCompounds.ContainsKey(_compound.RefID)) mDubCompounds[_compound.RefID] = _compound; mCompounds[_compound.RefID] = _compound; }
public Alnico(Compound parent, string name, Vector3D pos, double rot) : base(parent, name, pos, rot) { Priority = EPM.m_priority; Material = DefaultMaterial; Material.FillColor = new Material.Color(55, 55, 65, 255); Material.EdgeColor = new Material.Color(55, 55, 65, 255); LinearPolygon alnico = new LinearPolygon(this, Material, Priority, 0, 0, new double[,] { { 2.6, 2.6, 5.11, 5.11 }, { 0.91, 2.38, 2.38, 0.91} }, m_width); m_primitives.Add(alnico); }
private void InitialiseCompounds(XmlNode _node, Compound _parent) { ParseCompoundByNodeName(_node, _parent, "compound"); ParseCompoundByNodeName(_node, _parent, "member"); }
public EPM_2x2(Compound parent, string name, Vector3D pos, double rot) : base(parent, name, pos, rot) { foreach (double xx in new double[] { 0, 10.41 }) { m_compounds.Add(new Pole(this, "pole", new Vector3D(xx - 11.33 / 2, 0, 0), 0, 0.92)); } foreach (double xx in new double[] { 1.92, 4.74, 7.58 }) { m_compounds.Add(new Pole(this, "pole", new Vector3D(xx - 11.33 / 2, 0, 0), 0, 1.83)); } foreach (double xx in new double[] { 0.92, 3.75, 6.58, 9.41 }) { m_compounds.Add(new Alnico(this, "alnico", new Vector3D(xx - 11.33 / 2, 0, 0), 0)); m_compounds.Add(new Neodymium(this, "neodymium", new Vector3D(xx - 11.33 / 2, 0, 0), 0)); m_compounds.Add(new Coil(this, "coil", new Vector3D(xx - 11.33 / 2, 0, 0), 0)); } }
private void WriteCompound(XmlElement _node, Compound _compound) { foreach (Compound child in _compound) { XmlElement node = XmlUtility.CreateElement(_node, child.Kind); XmlUtility.CreateAttribute(node, "name", child.Name); XmlUtility.CreateAttribute(node, "id", child.RefID); WriteCompound(node, child); } }
public TableFormula SolubilityTableForPh(ParameterAlternative solubilityAlternative, Compound compound) { //Sol(pH) = ref_Solubility * Solubility_Factor (ref_pH) / Solubility_Factor(pH) //Solubility_pKa_pH_Factor var refPh = solubilityAlternative.Parameter(CoreConstants.Parameter.RefpH); var refSolubility = solubilityAlternative.Parameter(CoreConstants.Parameter.SolubilityAtRefpH); var gainPerCharge = solubilityAlternative.Parameter(CoreConstants.Parameter.SolubilityGainPerCharge); var refSolubilityValue = refSolubility.Value; var formula = _formulaFactory.CreateTableFormula() .WithName(PKSimConstants.UI.Solubility) .InitializedWith(PKSimConstants.UI.pH, PKSimConstants.UI.Solubility, refPh.Dimension, refSolubility.Dimension); compound.Parameter(CoreConstants.Parameter.RefpH).Value = refPh.Value; compound.Parameter(CoreConstants.Parameter.SolubilityGainPerCharge).Value = gainPerCharge.Value; double solFactorRefpH = compound.Parameter(CoreConstants.Parameter.SOLUBILITY_P_KA__P_H_FACTOR).Value; var allPh = new List <double>(); int ph = 0; while (ph <= 13) { allPh.AddRange(new[] { ph, ph + 0.5 }); ph++; } allPh.Add(14); foreach (var pH in allPh) { compound.Parameter(CoreConstants.Parameter.RefpH).Value = pH; double solFactorAtpH = compound.Parameter(CoreConstants.Parameter.SOLUBILITY_P_KA__P_H_FACTOR).Value; formula.AddPoint(pH, refSolubilityValue * solFactorRefpH / solFactorAtpH); } return(formula); }
static void TestAraPhone() { Endo e = new Endo(null, "endo", new Vector3D(0, 0, 0), 0); Module_1x2 m1 = new Module_1x2("m1"); Module_2x2 m2 = new Module_2x2("m2"); Module_1x2 m4 = new Module_1x2("m4"); Module_2x2 m5 = new Module_2x2("m5"); Module_1x2 m6 = new Module_1x2("m6"); Module_1x2 m7 = new Module_1x2("m7"); XmlCompound u1 = new XmlCompound(m1, "u1", new Vector3D(0, 0, 0), 0); u1.Parse(XElement.Load("Box.xml")); u1.Transformations.Add(new TTranslate(20, 3, 3)); m5.Add(u1); //e.AddModule(1, m1); //e.AddModule(3, m2); //e.AddModule(4, m4); e.AddModule(5, m5); //e.AddModule(6, m6); //e.AddModule(7, m7); // Phantom Compound headPhantom = new Compound("head-phantom"); Dielectric skinMaterial = new Dielectric("skin", 50, kappa: 0.65, density: 1100); skinMaterial.FillColor = new Material.Color(245, 215, 205, 54); skinMaterial.EdgeColor = new Material.Color(255, 235, 217, 250); Sphere skin = new Sphere(null, skinMaterial, 11, new Vector3D(), 1); skin.Transformations.Add(new TScale(80, 100, 80)); headPhantom.Add(skin); Dielectric boneMaterial = new Dielectric("bone", 13, kappa: 0.1, density: 2000); boneMaterial.FillColor = new Material.Color(227, 227, 227, 54); boneMaterial.EdgeColor = new Material.Color(202, 202, 202, 250); Sphere bone = new Sphere(null, boneMaterial, 12, new Vector3D(), 1); bone.Transformations.Add(new TScale(75, 95, 75)); headPhantom.Add(bone); Dielectric brainMaterial = new Dielectric("brain", 60, kappa: 0.7, density: 1040); brainMaterial.FillColor = new Material.Color(255, 85, 127, 54); brainMaterial.EdgeColor = new Material.Color(71, 222, 179, 250); Sphere brain = new Sphere(null, brainMaterial, 13, new Vector3D(), 1); brain.Transformations.Add(new TScale(65, 85, 65)); headPhantom.Add(brain); headPhantom.Transformations.Add(new TTranslate(33, 70, 90)); Compound s = new Compound("space"); s.Add(e); s.Add(headPhantom); RectilinearGrid g = new SimpleGrid_6x3(); g.ZLines.Add(170); double airBox = 50; double maxRes = 5; double ratio = 1.5; g.AddAirbox(airBox); g.SmoothMesh(maxRes, ratio); s.Add(new SARBox("SAR", 1200e6, new Vector3D(), new Vector3D(20, 20, 20))); s.Add(new NF2FFBox("nf2ff", new Vector3D(g.XLines.First(), g.YLines.First(), g.ZLines.First()), new Vector3D(g.XLines.Last(), g.YLines.Last(), g.ZLines.Last()))); s.Add(new LumpedPort(100, 1, 50.0, new Vector3D(-0.1, -0.1, -1.25), new Vector3D(+0.1, +0.1, +1.25), ENormDir.Z, true)); Simulation fdtd = new Simulation(); fdtd.Excitation = new GaussExcitation(1e9, 1.5e9); g.AddPML(10); XDocument doc = new XDocument( new XDeclaration("1.0", "utf-8", "yes"), new XComment("Test XML file for CyPhy generated openEMS simulations"), new XElement("openEMS", fdtd.ToXElement(), new XElement("ContinuousStructure", new XAttribute("CoordSystem", 0), s.ToXElement(), g.ToXElement() ) ) ); doc.Save("CSXTest.xml"); }
public CompoundView(Compound item, SourceView master) : base(master, "Compound: " + item.NodeDump) { Client = item.CreateView(Master); Source = item.GetSource(); }
private void ParseType(List<AlphabetType> _commands, ref int _indexParse, XmlNode _typeDefinition) { while (true) { if (_indexParse >= _commands.Count) break; AlphabetType command = _commands[_indexParse]; _indexParse ++; if (command.Direction == StateDirection.Up) { break; } else if (command.Direction == StateDirection.Down) { CompoundType type = new CompoundType(); mTemplateTypes.Add(type); type.ParseType(_commands, ref _indexParse, _typeDefinition); } else { if (command.Element != null) { if (mBaseType == null) { string refid = command.Element.Attributes["refid"].Value; if (CompoundManager.Instance.IsIgnoredCompound(refid)) { ConsoleUtility.WriteErrorLine("{0} id and name {1} not found in type {2}", refid, command.Element.InnerText, _typeDefinition.InnerXml); } else { var compound = CompoundManager.Instance.GetCompound(refid); if (compound == null) { ConsoleUtility.WriteErrorLine("{0} id and name {1} not found in type {2}", refid, command.Element.InnerText, _typeDefinition.InnerXml); } else { mBaseType = compound; } } } else { ConsoleUtility.WriteErrorLine("Error parse type {0}", _typeDefinition.InnerXml); } } else if (command.Text != null) { mParseType += command.Text; } else { ConsoleUtility.WriteErrorLine("Error parse type {0}", _typeDefinition.InnerXml); } } } }
public Pole(Compound parent, string name, Vector3D pos, double rot, double width) : base(parent, name, pos, rot) { m_width = width; Priority = EPM.m_priority; Material = DefaultMaterial; Material.FillColor = new Material.Color(95, 95, 95, 255); Material.EdgeColor = new Material.Color(95, 95, 95, 255); LinearPolygon pole = new LinearPolygon(this, this.Material, this.Priority, 0, 0, new double[,] { { 0, 0, 5.11, 5.11, 3.59, 2.2 }, { 0, 2.38, 2.38, 0.91, 0.91, 0} }, m_width); m_primitives.Add(pole); }