{"action":"created","issue":{"url":"https://api.github.com/repos/modelica/fmi-standard/issues/308","repository_url":"https://api.github.com/repos/modelica/fmi-standard","labels_url":"https://api.github.com/repos/modelica/fmi-standard/issues/308/labels{/name}","comments_url":"https://api.github.com/repos/modelica/fmi-standard/issues/308/comments","events_url":"https://api.github.com/repos/modelica/fmi-standard/issues/308/events","html_url":"https://github.com/modelica/fmi-standard/issues/308","id":370837208,"node_id":"MDU6SXNzdWUzNzA4MzcyMDg=","number":308,"title":"Fix Pseudocode Example","user":{"login":"modelica-trac-importer","id":22202507,"node_id":"MDQ6VXNlcjIyMjAyNTA3","avatar_url":"https://avatars1.githubusercontent.com/u/22202507?v=4","gravatar_id":"","url":"https://api.github.com/users/modelica-trac-importer","html_url":"https://github.com/modelica-trac-importer","followers_url":"https://api.github.com/users/modelica-trac-importer/followers","following_url":"https://api.github.com/users/modelica-trac-importer/following{/other_user}","gists_url":"https://api.github.com/users/modelica-trac-importer/gists{/gist_id}","starred_url":"https://api.github.com/users/modelica-trac-importer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/modelica-trac-importer/subscriptions","organizations_url":"https://api.github.com/users/modelica-trac-importer/orgs","repos_url":"https://api.github.com/users/modelica-trac-importer/repos","events_url":"https://api.github.com/users/modelica-trac-importer/events{/privacy}","received_events_url":"https://api.github.com/users/modelica-trac-importer/received_events","type":"User","site_admin":false},"labels":[{"id":1093397540,"node_id":"MDU6TGFiZWwxMDkzMzk3NTQw","url":"https://api.github.com/repos/modelica/fmi-standard/labels/P:%20major","name":"P: major","color":"f6f6f6","default":false},{"id":1046392991,"node_id":"MDU6TGFiZWwxMDQ2MzkyOTkx","url":"https://api.github.com/repos/modelica/fmi-standard/labels/bug","name":"bug","color":"d73a4a","default":true},{"id":1093395658,"node_id":"MDU6TGFiZWwxMDkzMzk1NjU4","url":"https://api.github.com/repos/modelica/fmi-standard/labels/specification","name":"specification","color":"0000aa","default":false}],"state":"open","locked":false,"assignee":{"login":"TorstenBlochwitz","id":33951596,"node_id":"MDQ6VXNlcjMzOTUxNTk2","avatar_url":"https://avatars1.githubusercontent.com/u/33951596?v=4","gravatar_id":"","url":"https://api.github.com/users/TorstenBlochwitz","html_url":"https://github.com/TorstenBlochwitz","followers_url":"https://api.github.com/users/TorstenBlochwitz/followers","following_url":"https://api.github.com/users/TorstenBlochwitz/following{/other_user}","gists_url":"https://api.github.com/users/TorstenBlochwitz/gists{/gist_id}","starred_url":"https://api.github.com/users/TorstenBlochwitz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TorstenBlochwitz/subscriptions","organizations_url":"https://api.github.com/users/TorstenBlochwitz/orgs","repos_url":"https://api.github.com/users/TorstenBlochwitz/repos","events_url":"https://api.github.com/users/TorstenBlochwitz/events{/privacy}","received_events_url":"https://api.github.com/users/TorstenBlochwitz/received_events","type":"User","site_admin":false},"assignees":[{"login":"TorstenBlochwitz","id":33951596,"node_id":"MDQ6VXNlcjMzOTUxNTk2","avatar_url":"https://avatars1.githubusercontent.com/u/33951596?v=4","gravatar_id":"","url":"https://api.github.com/users/TorstenBlochwitz","html_url":"https://github.com/TorstenBlochwitz","followers_url":"https://api.github.com/users/TorstenBlochwitz/followers","following_url":"https://api.github.com/users/TorstenBlochwitz/following{/other_user}","gists_url":"https://api.github.com/users/TorstenBlochwitz/gists{/gist_id}","starred_url":"https://api.github.com/users/TorstenBlochwitz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TorstenBlochwitz/subscriptions","organizations_url":"https://api.github.com/users/TorstenBlochwitz/orgs","repos_url":"https://api.github.com/users/TorstenBlochwitz/repos","events_url":"https://api.github.com/users/TorstenBlochwitz/events{/privacy}","received_events_url":"https://api.github.com/users/TorstenBlochwitz/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/modelica/fmi-standard/milestones/3","html_url":"https://github.com/modelica/fmi-standard/milestone/3","labels_url":"https://api.github.com/repos/modelica/fmi-standard/milestones/3/labels","id":3743791,"node_id":"MDk6TWlsZXN0b25lMzc0Mzc5MQ==","number":3,"title":"FMI 2.0.1","description":"","creator":{"login":"modelica-trac-importer","id":22202507,"node_id":"MDQ6VXNlcjIyMjAyNTA3","avatar_url":"https://avatars1.githubusercontent.com/u/22202507?v=4","gravatar_id":"","url":"https://api.github.com/users/modelica-trac-importer","html_url":"https://github.com/modelica-trac-importer","followers_url":"https://api.github.com/users/modelica-trac-importer/followers","following_url":"https://api.github.com/users/modelica-trac-importer/following{/other_user}","gists_url":"https://api.github.com/users/modelica-trac-importer/gists{/gist_id}","starred_url":"https://api.github.com/users/modelica-trac-importer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/modelica-trac-importer/subscriptions","organizations_url":"https://api.github.com/users/modelica-trac-importer/orgs","repos_url":"https://api.github.com/users/modelica-trac-importer/repos","events_url":"https://api.github.com/users/modelica-trac-importer/events{/privacy}","received_events_url":"https://api.github.com/users/modelica-trac-importer/received_events","type":"User","site_admin":false},"open_issues":10,"closed_issues":1,"state":"open","created_at":"2018-10-16T17:10:41Z","updated_at":"2018-10-16T23:17:28Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2018-10-16T23:17:28Z","updated_at":"2018-10-16T23:17:47Z","closed_at":null,"author_association":"COLLABORATOR","body":"**Reported by rfranke on 8 Dec 2014 07:44 UTC**\nThe pseudocode example for model exchange given in section 2.3.4 of the specification document doesn't check for time events at model initialization. It is proposed to use the following modified pseudocode instead, which\n•\tfixes the treatment of time events after initialization\n•\tmoves all event processing to one place in the simulation loop – according to the calling sequence in Figure 6,\n•\tremoves the call to fmi2SetTime during initialization (see also #296 and #294),\n•\tdefines the initialization of event indicators with zeros,\n•\tremoves undefined eps from detection of time events – there finds other places that also do comparisons without eps, like “while time < Tend loop”,\n•\tunifies capitalization\n\nI prepared a Word document with change marks, FunctionalMockupInterface_v2.0.1-MaplesoftEdits-Pseudocode.docx, that could be added to the SVN or requested by e-mail.\n\nTwo questions arise:\n1. Is the initialization of event indicators with zeros correct?\n2. Does the retrieval of states have to check for initialEventMode or would the FMU set `eventInfo.valuesOfContinuousStatesChanged` and `eventInfo.nominalsOfContinuousStatesChanged` anyway during initialization?\n\n```\nm = M_fmi2Instantiate(\"m\", ...)  // \"m\" is the instance name\n                                // \"M_\" is the MODEL_IDENTIFIER\nnx     = ...   // number of states, from XML file\nnz     = ...   // number of event indicators, from XML file\ntStart = 0     // could also be retrieved from XML file\ntEnd   = 10    // could also be retrieved from XML file\ndt     = 0.01  // fixed step size of 10 milli-seconds\n\n// set the start time\ntime  = tStart\n\n// set all variable start values (of \"ScalarVariable / <type> / start\") and\n// set the input values at time = tStart\nM_fmi2SetReal/Integer/Boolean/String(m, ...)\n\n// initialize\nM_fmi2SetupExperiment(m,fmi2False,0.0, Tstart, fmi2True,Tend)\nM_fmi2EnterInitializationMode(m)\nM_fmi2ExitInitializationMode(m)\n\ninitialEventMode = fmi2True\nenterEventMode = fmi2False\ntimeEvent = fmi2False\nstateEvent = fmi2False\nprevious_z = zeros(nz)\n\ndo\n  // handle events\n  if initialEventMode or enterEventMode or timeEvent or stateEvent then\n    if not initialEventMode then\n      M_fmi2EnterEventMode(m)\n    end if\n\n    // event iteration\n    eventInfo.newDiscreteStatesNeeded = fmi2True;\n    while eventInfo.newDiscreteStatesNeeded loop\n      // update discrete states\n      M_fmi2NewDiscreteStates(m, &eventInfo)\n      if eventInfo.terminateSimulation then goto TERMINATE_MODEL\n    end while\n\n    // enter Continuous-Time Mode\n    M_fmi2EnterContinuousTimeMode(m)\n\n    // retrieve solution at simulation (re)start\n    M_fmi2GetReal/Integer/Boolean/String(m, ...)\n    if initialEventMode or eventInfo.valuesOfContinuousStatesChanged then\n      //the model signals a value change of states, retrieve them\n      M_fmi2GetContinuousStates(m, x, nx)\n    end if\n\n    if initialEventMode or eventInfo.nominalsOfContinuousStatesChanged then\n      //the meaning of states has changed; retrieve new nominal values\n      M_fmi2GetNominalsOfContinuousStates(m, x_nominal, nx)\n    end if\n\n    if eventInfo.nextEventTimeDefined then\n       tNext = min(eventInfo.nextEventTime, tEnd)\n    else\n       tNext = tEnd\n    end if\n\n    initialEventMode = fmi2False\n  end if\n\n  if time >= tEnd then\n    goto TERMINATE_MODEL\n  end if\n\n  // compute derivatives\n  M_fmi2GetDerivatives(m, der_x, nx)\n\n  // advance time\n  h    = min(dt, tNext-time)\n  time = time + h\n  M_fmi2SetTime(m, time)\n\n  // set inputs at t = time\n  M_fmi2SetReal/Integer/Boolean/String(m, ...)\n\n  // set states at t = time and perform one step\n  x = x + h*der_x  // forward Euler method\n  M_fmi2SetContinuousStates(m, x, nx)\n\n  // get event indicators at t = time\n  M_fmi2GetEventIndicators(m, z, nz)\n\n  // detect  events, if any\n  timeEvent = time >= tNext\n  stateEvent = sign(z) <> sign(previous_z)\n  previous_z = z\n\n  // inform the model about an accepted step\n  M_fmi2CompletedIntegratorStep(m, fmi2True, &enterEventMode,\n                                             &terminateSimulation)\nuntil terminateSimulation\n\n// terminate simulation and retrieve final values\nTERMINATE_MODEL:\nM_fmi2Terminate(m)\nM_fmi2GetReal/Integer/Boolean/String(m, ...)\n\n// cleanup\nM_fmi2FreeInstance(m)\n```\n\n----\n\nMigrated-From: https://trac.fmi-standard.org/ticket/308"},"comment":{"url":"https://api.github.com/repos/modelica/fmi-standard/issues/comments/430434324","html_url":"https://github.com/modelica/fmi-standard/issues/308#issuecomment-430434324","issue_url":"https://api.github.com/repos/modelica/fmi-standard/issues/308","id":430434324,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMDQzNDMyNA==","user":{"login":"modelica-trac-importer","id":22202507,"node_id":"MDQ6VXNlcjIyMjAyNTA3","avatar_url":"https://avatars1.githubusercontent.com/u/22202507?v=4","gravatar_id":"","url":"https://api.github.com/users/modelica-trac-importer","html_url":"https://github.com/modelica-trac-importer","followers_url":"https://api.github.com/users/modelica-trac-importer/followers","following_url":"https://api.github.com/users/modelica-trac-importer/following{/other_user}","gists_url":"https://api.github.com/users/modelica-trac-importer/gists{/gist_id}","starred_url":"https://api.github.com/users/modelica-trac-importer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/modelica-trac-importer/subscriptions","organizations_url":"https://api.github.com/users/modelica-trac-importer/orgs","repos_url":"https://api.github.com/users/modelica-trac-importer/repos","events_url":"https://api.github.com/users/modelica-trac-importer/events{/privacy}","received_events_url":"https://api.github.com/users/modelica-trac-importer/received_events","type":"User","site_admin":false},"created_at":"2018-10-16T23:17:47Z","updated_at":"2018-10-16T23:17:47Z","author_association":"COLLABORATOR","body":"**Comment by aviel on 13 Feb 2017 14:20 UTC**\nThis ticket seems to be related to ticket #333. By the way, it is not clear if the Pseudo Code Example is meant to be exhaustive with respect to all possible cases implied by the specification. If this is the case, this ticket is actually filed with _major_ priority, and the Pseudo Code Example should also take into account the pure discrete time variant of FMI. If it is not the case, it should be filed with _minor_ priority and the only requirement for a 2.0.1 maintenance release is to fix what is wrong in the example with respect to the specification (like the call to `fmi2SetTime` after the instantiation, as it is already reported by ticket #296), and nothing more."}}
{"actor":{"display_login":"modelica-trac-importer"}}